From 100b678e82866b707429fd69d4ba257687a4e297 Mon Sep 17 00:00:00 2001 From: John-Weak Date: Mon, 16 Dec 2024 09:45:00 +0530 Subject: [PATCH 1/2] [user-management] add option to disable 2fa for a user --- .../javascripts/countly.models.js | 16 ++++++++++++++++ .../javascripts/countly.views.js | 19 +++++++++++++++++++ .../user-management/templates/data-table.html | 1 + .../dashboard/dashboard.properties | 1 + 4 files changed, 37 insertions(+) diff --git a/frontend/express/public/core/user-management/javascripts/countly.models.js b/frontend/express/public/core/user-management/javascripts/countly.models.js index 147224b3f7b..a87d85aff40 100644 --- a/frontend/express/public/core/user-management/javascripts/countly.models.js +++ b/frontend/express/public/core/user-management/javascripts/countly.models.js @@ -215,5 +215,21 @@ callback(err.responseJSON.result); }); }; + countlyUserManagement.disableTwoFactorAuth = function(id, callback) { + return $.ajax({ + type: "GET", + url: countlyGlobal.path + "/i/two-factor-auth", + data: { + method: "admin_disable", + uid: id + }, + success: function() { + callback(); + }, + error: function(err) { + callback(err.responseJSON.result); + } + }); + }; })((window.countlyUserManagement = window.countlyUserManagement || {})); diff --git a/frontend/express/public/core/user-management/javascripts/countly.views.js b/frontend/express/public/core/user-management/javascripts/countly.views.js index 011c875c7d2..6cb5584eb56 100644 --- a/frontend/express/public/core/user-management/javascripts/countly.views.js +++ b/frontend/express/public/core/user-management/javascripts/countly.views.js @@ -65,6 +65,7 @@ }, roleMap: roleMap, showLogs: countlyGlobal.plugins.indexOf('systemlogs') > -1, + twoFactorAuth: countlyGlobal.plugins.indexOf('two-factor-auth') > -1, tableDynamicCols: tableDynamicCols, userManagementPersistKey: 'userManagement_table_' + countlyCommon.ACTIVE_APP_ID, isGroupPluginEnabled: isGroupPluginEnabled @@ -114,6 +115,9 @@ } }, methods: { + is2faEnabled: function(row) { + return countlyGlobal.member.global_admin && this.twoFactorAuth && row.two_factor_auth && row.two_factor_auth.enabled; + }, handleCommand: function(command, index) { switch (command) { case "delete-user": @@ -157,6 +161,21 @@ }); }); break; + case 'disable-2fa': + countlyUserManagement.disableTwoFactorAuth(index, function(err) { + if (err) { + CountlyHelpers.notify({ + message: CV.i18n('two-factor-auth.faildisable_title'), + type: 'error' + }); + return; + } + CountlyHelpers.notify({ + message: CV.i18n('two-factor-auth.disable_title'), + type: 'success' + }); + }); + break; } }, handleSubmitFilter: function(newFilter) { diff --git a/frontend/express/public/core/user-management/templates/data-table.html b/frontend/express/public/core/user-management/templates/data-table.html index 571376f6630..fa8f4b1bb0c 100644 --- a/frontend/express/public/core/user-management/templates/data-table.html +++ b/frontend/express/public/core/user-management/templates/data-table.html @@ -129,6 +129,7 @@

{{i18n('management-users.view-title')}}

{{ i18n('management-users.view-user-logs') }} {{ i18n('management-users.reset-failed-logins') }} {{ i18n('management-users.delete-user') }} + {{ i18n('management-users.disable-2fa-user') }} diff --git a/frontend/express/public/localization/dashboard/dashboard.properties b/frontend/express/public/localization/dashboard/dashboard.properties index 0eaa9b14346..0b1a5340f46 100644 --- a/frontend/express/public/localization/dashboard/dashboard.properties +++ b/frontend/express/public/localization/dashboard/dashboard.properties @@ -908,6 +908,7 @@ management-users.no-role = No role management-users.create-user = Create User management-users.delete-user = Delete User management-users.edit = Click to edit +management-users.disable-2fa-user = Disable 2FA management-users.all-roles = All roles management-users.not-logged-in-yet = Not logged in yet management-users.close = Click to close From 5c1d905c55cc179a0d6cc504e6d118acc863bd1b Mon Sep 17 00:00:00 2001 From: John-Weak Date: Mon, 16 Dec 2024 09:50:15 +0530 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 785de3e059a..bbb6732d036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ Fixes: - [push] Fixed bug where IOS credentials get mixed up while sending messages from different apps at the same time - [push] Fixed bug where it crashes in connection pool growth because of a type mismatch in an if condition +Features: +- [user-management] Global admins can now disable 2FA for individual users + Dependencies: - Bump express from 4.21.1 to 4.21.2 - Bump mocha from 10.2.0 to 10.8.2