migrate permissions and admin flag to user.role
This commit is contained in:
@@ -99,7 +99,8 @@ function actionForAllAdmins(skippingUserIds, iterator, callback) {
|
||||
assert.strictEqual(typeof iterator, 'function');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
users.getAllAdmins(function (error, result) {
|
||||
users.getAdmins(function (error, result) {
|
||||
if (error && error.reason === BoxError.NOT_FOUND) return callback();
|
||||
if (error) return callback(error);
|
||||
|
||||
// filter out users we want to skip (like the user who did the action or the user the action was performed on)
|
||||
@@ -133,14 +134,14 @@ function userRemoved(performedBy, eventId, user, callback) {
|
||||
}, callback);
|
||||
}
|
||||
|
||||
function adminChanged(performedBy, eventId, user, callback) {
|
||||
function roleChanged(performedBy, eventId, user, callback) {
|
||||
assert.strictEqual(typeof performedBy, 'string');
|
||||
assert.strictEqual(typeof user, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
actionForAllAdmins([ performedBy, user.id ], function (admin, done) {
|
||||
mailer.adminChanged(admin.email, user, user.admin);
|
||||
add(admin.id, eventId, `User '${user.displayName} ' ${user.admin ? 'is now an admin' : 'is no more an admin'}`, `User '${user.username || user.email || user.fallbackEmail}' ${user.admin ? 'is now an admin' : 'is no more an admin'}.`, done);
|
||||
mailer.roleChanged(admin.email, user);
|
||||
add(admin.id, eventId, `User '${user.displayName}'s role changed`, `User '${user.username || user.email || user.fallbackEmail}' now has the role '${user.role}'.`, done);
|
||||
}, callback);
|
||||
}
|
||||
|
||||
@@ -324,8 +325,8 @@ function onEvent(id, action, source, data, callback) {
|
||||
return userRemoved(source.userId, id, data.user, callback);
|
||||
|
||||
case eventlog.ACTION_USER_UPDATE:
|
||||
if (!data.adminStatusChanged) return callback();
|
||||
return adminChanged(source.userId, id, data.user, callback);
|
||||
if (!data.roleChanged) return callback();
|
||||
return roleChanged(source.userId, id, data.user, callback);
|
||||
|
||||
case eventlog.ACTION_APP_OOM:
|
||||
return oomEvent(id, data.app, data.addon, data.containerId, data.event, callback);
|
||||
|
||||
Reference in New Issue
Block a user