Do not set admin group multiple times

This commit is contained in:
Johannes Zellner
2016-02-26 10:56:33 +01:00
parent 6843fda601
commit 715c5f9f61

View File

@@ -271,8 +271,11 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
return console.error('Unable to update user:', error);
}
if ($scope.useredit.superuser) $scope.useredit.groupIds.push('admin');
else $scope.useredit.groupIds = $scope.useredit.groupIds.filter(function (groupId) { return groupId !== 'admin'; });
if ($scope.useredit.superuser) {
if ($scope.useredit.groupIds.indexOf('admin') === -1) $scope.useredit.groupIds.push('admin');
} else {
$scope.useredit.groupIds = $scope.useredit.groupIds.filter(function (groupId) { return groupId !== 'admin'; });
}
Client.setGroups(data.id, $scope.useredit.groupIds, function (error) {
$scope.useredit.busy = false;