Skip to content

Commit 5bebc89

Browse files
Merge pull request #5869 from Countly/SER-2177
[SER-2177] Adding 'disable 2FA' option in the user management > users
2 parents 8f36342 + 3cab7e9 commit 5bebc89

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Fixes:
33
- [push] Fixed bug where IOS credentials get mixed up while sending messages from different apps at the same time
44
- [push] Fixed bug where it crashes in connection pool growth because of a type mismatch in an if condition
55

6+
Features:
7+
- [user-management] Global admins can now disable 2FA for individual users
8+
69
Dependencies:
710
- Bump express from 4.21.1 to 4.21.2
811
- Bump mocha from 10.2.0 to 10.8.2

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

+16
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,21 @@
215215
callback(err.responseJSON.result);
216216
});
217217
};
218+
countlyUserManagement.disableTwoFactorAuth = function(id, callback) {
219+
return $.ajax({
220+
type: "GET",
221+
url: countlyGlobal.path + "/i/two-factor-auth",
222+
data: {
223+
method: "admin_disable",
224+
uid: id
225+
},
226+
success: function() {
227+
callback();
228+
},
229+
error: function(err) {
230+
callback(err.responseJSON.result);
231+
}
232+
});
233+
};
218234

219235
})((window.countlyUserManagement = window.countlyUserManagement || {}));

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

+19
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
},
6666
roleMap: roleMap,
6767
showLogs: countlyGlobal.plugins.indexOf('systemlogs') > -1,
68+
twoFactorAuth: countlyGlobal.plugins.indexOf('two-factor-auth') > -1,
6869
tableDynamicCols: tableDynamicCols,
6970
userManagementPersistKey: 'userManagement_table_' + countlyCommon.ACTIVE_APP_ID,
7071
isGroupPluginEnabled: isGroupPluginEnabled
@@ -114,6 +115,9 @@
114115
}
115116
},
116117
methods: {
118+
is2faEnabled: function(row) {
119+
return countlyGlobal.member.global_admin && this.twoFactorAuth && row.two_factor_auth && row.two_factor_auth.enabled;
120+
},
117121
handleCommand: function(command, index) {
118122
switch (command) {
119123
case "delete-user":
@@ -157,6 +161,21 @@
157161
});
158162
});
159163
break;
164+
case 'disable-2fa':
165+
countlyUserManagement.disableTwoFactorAuth(index, function(err) {
166+
if (err) {
167+
CountlyHelpers.notify({
168+
message: CV.i18n('two-factor-auth.faildisable_title'),
169+
type: 'error'
170+
});
171+
return;
172+
}
173+
CountlyHelpers.notify({
174+
message: CV.i18n('two-factor-auth.disable_title'),
175+
type: 'success'
176+
});
177+
});
178+
break;
160179
}
161180
},
162181
handleSubmitFilter: function(newFilter) {

frontend/express/public/core/user-management/templates/data-table.html

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ <h4>{{i18n('management-users.view-title')}}</h4>
131131
<el-dropdown-item v-if="showLogs" command="show-logs" :data-test-id="'datatable-users-more-button-view-logs-select-' + rowScope.$index">{{ i18n('management-users.view-user-logs') }}</el-dropdown-item>
132132
<el-dropdown-item command="reset-logins" :data-test-id="'datatable-users-more-button-reset-logins-select-' + rowScope.$index">{{ i18n('management-users.reset-failed-logins') }}</el-dropdown-item>
133133
<el-dropdown-item command="delete-user" :data-test-id="'datatable-users-more-button-delete-user-select-' + rowScope.$index">{{ i18n('management-users.delete-user') }}</el-dropdown-item>
134+
<el-dropdown-item v-if="is2faEnabled(rowScope.row)" command="disable-2fa" :data-test-id="'datatable-users-more-button-disable-2fa-select-' + rowScope.$index">{{ i18n('management-users.disable-2fa-user') }}</el-dropdown-item>
134135
</cly-more-options>
135136
</template>
136137
</el-table-column>

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

+1
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ management-users.no-role = No role
908908
management-users.create-user = Create User
909909
management-users.delete-user = Delete User
910910
management-users.edit = Click to edit
911+
management-users.disable-2fa-user = Disable 2FA
911912
management-users.all-roles = All roles
912913
management-users.not-logged-in-yet = Not logged in yet
913914
management-users.close = Click to close

0 commit comments

Comments
 (0)