Another attempt on fixing the user edit with roles business
This commit is contained in:
@@ -25,6 +25,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
$scope.config = Client.getConfig();
|
||||
$scope.userInfo = Client.getUserInfo();
|
||||
|
||||
// Order matters for permissions used in canEdit
|
||||
$scope.roles = [
|
||||
{ id: 'user', name: 'User', disabled: false },
|
||||
{ id: 'usermanager', name: 'User Manager', disabled: true },
|
||||
@@ -48,6 +49,13 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
return group.userIds.filter(function (uid) { return !!$scope.allUsersById[uid]; }).map(function (uid) { return $scope.allUsersById[uid].username || $scope.allUsersById[uid].email; }).join(' ');
|
||||
};
|
||||
|
||||
$scope.canEdit = function (user) {
|
||||
let roleInt1 = $scope.roles.findIndex(function (role) { return role.id === $scope.userInfo.role; });
|
||||
let roleInt2 = $scope.roles.findIndex(function (role) { return role.id === user.role; });
|
||||
|
||||
return (roleInt1 - roleInt2) >= 0;
|
||||
};
|
||||
|
||||
$scope.userremove = {
|
||||
busy: false,
|
||||
error: null,
|
||||
|
||||
Reference in New Issue
Block a user