No need to again check the groups for admin
This is already in user.get() which is attached to req.user
This commit is contained in:
committed by
Girish Ramakrishnan
parent
57d2fda14c
commit
94ee636254
+8
-13
@@ -8,7 +8,6 @@ exports = module.exports = {
|
||||
};
|
||||
|
||||
var assert = require('assert'),
|
||||
groups = require('../groups.js'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
user = require('../user.js'),
|
||||
@@ -23,18 +22,14 @@ function auditSource(req) {
|
||||
function get(req, res, next) {
|
||||
assert.strictEqual(typeof req.user, 'object');
|
||||
|
||||
groups.isMember(groups.ADMIN_GROUP_ID, req.user.id, function (error, isAdmin) {
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(200, {
|
||||
id: req.user.id,
|
||||
username: req.user.username,
|
||||
email: req.user.email,
|
||||
admin: isAdmin,
|
||||
displayName: req.user.displayName,
|
||||
showTutorial: req.user.showTutorial
|
||||
}));
|
||||
});
|
||||
next(new HttpSuccess(200, {
|
||||
id: req.user.id,
|
||||
username: req.user.username,
|
||||
email: req.user.email,
|
||||
admin: req.user.admin,
|
||||
displayName: req.user.displayName,
|
||||
showTutorial: req.user.showTutorial
|
||||
}));
|
||||
}
|
||||
|
||||
function update(req, res, next) {
|
||||
|
||||
Reference in New Issue
Block a user