logged: function(req, res, next) {
const callback = () => {
if (!loggedIn)
- return res.redirect("/");
+ return res.json({errmsg: "Not logged in"});
next();
};
let loggedIn = undefined;
// Just a quick heuristic, which should be enough
const loggedIn = !!req.cookies.token;
if (loggedIn)
- return res.redirect("/");
+ return res.json({errmsg: "Already logged in"});
next();
},
// Prevent direct access to AJAX results
ajax: function(req, res, next) {
- if (!req.xhr)
+ if (!req.xhr)
return res.json({errmsg: "Unauthorized access"});
next();
},