Revert role support
This commit is contained in:
27
src/users.js
27
src/users.js
@@ -14,7 +14,6 @@ exports = module.exports = {
|
||||
verifyWithEmail: verifyWithEmail,
|
||||
remove: removeUser,
|
||||
get: get,
|
||||
getWithRoles: getWithRoles,
|
||||
getByResetToken: getByResetToken,
|
||||
getAllAdmins: getAllAdmins,
|
||||
resetPasswordByIdentifier: resetPasswordByIdentifier,
|
||||
@@ -27,7 +26,9 @@ exports = module.exports = {
|
||||
setTwoFactorAuthenticationSecret: setTwoFactorAuthenticationSecret,
|
||||
enableTwoFactorAuthentication: enableTwoFactorAuthentication,
|
||||
disableTwoFactorAuthentication: disableTwoFactorAuthentication,
|
||||
transferOwnership: transferOwnership
|
||||
transferOwnership: transferOwnership,
|
||||
|
||||
isAdmin: isAdmin
|
||||
};
|
||||
|
||||
var apps = require('./apps.js'),
|
||||
@@ -323,6 +324,10 @@ function count(callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function isAdmin(user) {
|
||||
return user.groupIds.indexOf(constants.ADMIN_GROUP_ID) !== -1;
|
||||
}
|
||||
|
||||
function get(userId, callback) {
|
||||
assert.strictEqual(typeof userId, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
@@ -341,24 +346,6 @@ function get(userId, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function getWithRoles(userId, callback) {
|
||||
assert.strictEqual(typeof userId, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
userdb.get(userId, function (error, result) {
|
||||
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UsersError(UsersError.NOT_FOUND));
|
||||
if (error) return callback(new UsersError(UsersError.INTERNAL_ERROR, error));
|
||||
|
||||
groups.getGroups(userId, function (error, userGroups) {
|
||||
if (error) return callback(new UsersError(UsersError.INTERNAL_ERROR, error));
|
||||
|
||||
result.roles = _.uniq(_.flatten(userGroups.map(function (r) { return r.roles; })));
|
||||
|
||||
return callback(null, result);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getByResetToken(email, resetToken, callback) {
|
||||
assert.strictEqual(typeof email, 'string');
|
||||
assert.strictEqual(typeof resetToken, 'string');
|
||||
|
||||
Reference in New Issue
Block a user