updated revoke session middleware to allow self or admin or global mod invocation, tweaked tests a bit

This commit is contained in:
Julian Lam
2016-12-02 10:50:42 -05:00
parent aad9a39f02
commit 33ff5e09bb
5 changed files with 14 additions and 9 deletions

View File

@@ -49,8 +49,16 @@ middleware.authenticate = function (req, res, next) {
controllers.helpers.notAllowed(req, res);
};
middleware.ensureGlobalPrivilege = function (req, res, next) {
middleware.ensureSelfOrGlobalPrivilege = function (req, res, next) {
/*
The "self" part of this middleware hinges on you having used
middleware.exposeUid prior to invoking this middleware.
*/
if (req.user) {
if (req.user.uid === res.locals.uid) {
return next();
}
user.isAdminOrGlobalMod(req.uid, function (err, ok) {
if (err) {
return next(err);