3 // Prevent access to "users pages"
4 logged: function(req
, res
, next
) {
6 return res
.redirect("/");
10 // Prevent access to "anonymous pages"
11 unlogged: function(req
, res
, next
) {
13 return res
.redirect("/");
17 // Prevent direct access to AJAX results
18 ajax: function(req
, res
, next
) {
20 return res
.json({errmsg: "Unauthorized access"});
24 // Check for errors before callback (continue page loading). TODO: better name.
25 checkRequest: function(res
, err
, out
, msg
, cb
) {
27 return res
.json({errmsg: err
.errmsg
|| err
.toString()});
29 || (Array
.isArray(out
) && out
.length
== 0)
30 || (typeof out
=== "object" && Object
.keys(out
).length
== 0))
32 return res
.json({errmsg: msg
});