Skip to content

Commit

Permalink
Warning a user when delete their own account
Browse files Browse the repository at this point in the history
Fixing #137
  • Loading branch information
Kræn Hansen committed Nov 7, 2017
1 parent 011ef1c commit bd1de4f
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/ui/server-administration/users/UsersTableContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,22 @@ export class UsersTableContainer extends RealmLoadingComponent<
});
};

private confirmUserDeletion(userId: string): Promise<boolean> {
return new Promise((resolve, reject) => {
electron.remote.dialog.showMessageBox(
electron.remote.getCurrentWindow(),
{
type: 'warning',
message: `Are you sure you want to delete this user?`,
title: `Deleting ${userId}`,
buttons: ['Cancel', 'Delete'],
},
response => {
resolve(response === 1);
},
);
});
private confirmUserDeletion(userId: string): boolean {
const isCurrentUser = userId === this.props.user.identity;
const extraMessage = isCurrentUser
? '\n\nThis will delete the user on which you are currently logged in!'
: '';

const result = electron.remote.dialog.showMessageBox(
electron.remote.getCurrentWindow(),
{
type: 'warning',
message: 'Are you sure you want to delete the user?' + extraMessage,
title: `Deleting ${userId}`,
buttons: ['Cancel', isCurrentUser ? 'Delete my user' : 'Delete'],
},
);

return result === 1;
}
}

0 comments on commit bd1de4f

Please sign in to comment.