Skip to content
Snippets Groups Projects
Commit fc1ef400 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

make sure user can't remove the last admin.

parent c9fb2eb1
Branches
Tags
No related merge requests found
......@@ -54,7 +54,15 @@ export default class AdminPeople extends Component {
onRoleChange(user, roleDef) {
if (roleDef.id === "user" && user.is_superuser) {
this.props.dispatch(revokeAdmin(user));
// check that this isn't the last admin in the system
let admins = _.pick(this.props.users, function(value, key, object) {
return value.is_superuser;
});
if (admins && _.keys(admins).length > 1) {
this.props.dispatch(revokeAdmin(user));
}
} else if (roleDef.id === "admin" && !user.is_superuser) {
this.props.dispatch(grantAdmin(user));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment