Skip to content

Commit 1e9d226

Browse files
Merge pull request #6051 from Countly/SER-2341
[SER-2341] Add error message when global admin tries to remove itself
2 parents b5112d1 + 3cb3fa2 commit 1e9d226

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Version 24.05.27
22
Fixes:
33
- [crashes] Remove memory addresses from stack trace grouping
4+
- [user-management] Prevent global admin from self-revoke and self-delete
45

56
Enterprise Fixes:
67
- [cohorts] Fixed issue with combining multiple cohorts

frontend/express/public/core/user-management/javascripts/countly.views.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@
118118
switch (command) {
119119
case "delete-user":
120120
var self = this;
121+
122+
// Check if user is trying to delete themselves
123+
if (index === countlyGlobal.member._id) {
124+
CountlyHelpers.notify({
125+
type: 'error',
126+
message: CV.i18n('management-users.cannot-delete-own-account')
127+
});
128+
return;
129+
}
130+
121131
CountlyHelpers.confirm(CV.i18n('management-users.this-will-delete-user'), "red", function(result) {
122132
if (!result) {
123133
CountlyHelpers.notify({
@@ -693,6 +703,15 @@
693703
// drawer event handlers
694704
onClose: function() {},
695705
onSubmit: function(submitted, done) {
706+
if (submitted._id === countlyGlobal.member._id && countlyGlobal.member.global_admin && !submitted.global_admin) {
707+
CountlyHelpers.notify({
708+
message: CV.i18n('management-users.cannot-revoke-own-admin'),
709+
type: 'error'
710+
});
711+
done(CV.i18n('management-users.cannot-revoke-own-admin'));
712+
return;
713+
}
714+
696715
var atLeastOneAppSelected = false;
697716

698717
for (var i = 0; i < submitted.permission._.u.length; i++) {

frontend/express/public/localization/dashboard/dashboard.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,8 @@ management-users.search-placeholder = Search in Features
946946
management-users.reset-failed-logins = Reset failed logins
947947
management-users.reset-failed-logins-success = Failed logins reset successfully\!
948948
management-users.reset-failed-logins-failed = Failed to reset logins\!
949+
management-users.cannot-delete-own-account = You can not delete your own account
950+
management-users.cannot-revoke-own-admin = You can not revoke your own global admin privileges
949951

950952
#date-preset
951953
management.preset = Date presets

0 commit comments

Comments
 (0)