3 // Prevent access to "users pages"
4 Access
.logged = function(req
, res
, next
)
7 return res
.redirect("/");
11 // Prevent access to "anonymous pages"
12 Access
.unlogged = function(req
, res
, next
)
15 return res
.redirect("/");
19 // Prevent direct access to AJAX results
20 Access
.ajax = function(req
, res
, next
)
23 return res
.json({errmsg: "Unauthorized access"});
27 // Check for errors before callback (continue page loading). TODO: better name.
28 Access
.checkRequest = function(res
, err
, out
, msg
, cb
)
33 || (Array
.isArray(out
) && out
.length
== 0)
34 || (typeof out
=== "object" && Object
.keys(out
).length
== 0))
36 return res
.json({errmsg: msg
});
41 module
.exports
= Access
;