X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=utils%2Faccess.js;fp=utils%2Faccess.js;h=0000000000000000000000000000000000000000;hb=625022fdcf750f0aff8fcd699f7e9b89730e1d10;hp=49d204c3483818213ea8c2affd4ae085bd9dc6f2;hpb=b955c65b942d09d24b5c3bed0d755d4f2f8f71f1;p=vchess.git diff --git a/utils/access.js b/utils/access.js deleted file mode 100644 index 49d204c3..00000000 --- a/utils/access.js +++ /dev/null @@ -1,36 +0,0 @@ -module.exports = -{ - // Prevent access to "users pages" - logged: function(req, res, next) { - if (req.userId == 0) - return res.redirect("/"); - next(); - }, - - // Prevent access to "anonymous pages" - unlogged: function(req, res, next) { - if (req.userId > 0) - return res.redirect("/"); - next(); - }, - - // Prevent direct access to AJAX results - ajax: function(req, res, next) { - if (!req.xhr) - return res.json({errmsg: "Unauthorized access"}); - next(); - }, - - // Check for errors before callback (continue page loading). TODO: better name. - checkRequest: function(res, err, out, msg, cb) { - if (!!err) - return res.json({errmsg: err.errmsg || err.toString()}); - if (!out - || (Array.isArray(out) && out.length == 0) - || (typeof out === "object" && Object.keys(out).length == 0)) - { - return res.json({errmsg: msg}); - } - cb(); - }, -}