From 5187440e7318ece669d0c4beaade48c436024711 Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Sat, 2 May 2020 20:56:12 +0200 Subject: [PATCH] #1303 Add MFA disable confirm in user settings page --- .../app/scripts/controllers/SettingsCtrl.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/frontend/app/scripts/controllers/SettingsCtrl.js b/frontend/app/scripts/controllers/SettingsCtrl.js index 39384d42fa..222b6cab06 100644 --- a/frontend/app/scripts/controllers/SettingsCtrl.js +++ b/frontend/app/scripts/controllers/SettingsCtrl.js @@ -1,7 +1,7 @@ (function() { 'use strict'; angular.module('theHiveControllers').controller('SettingsCtrl', - function($scope, $state, UserSrv, AuthenticationSrv, NotificationSrv, clipboard, resizeService, readLocalPicService, currentUser, appConfig) { + function($scope, $state, UserSrv, ModalSrv, AuthenticationSrv, NotificationSrv, clipboard, resizeService, readLocalPicService, currentUser, appConfig) { $scope.currentUser = currentUser; $scope.appConfig = appConfig; @@ -126,14 +126,26 @@ }; $scope.resetMfa = function() { - UserSrv.resetMfa() - .then(function(/*response*/) { + var modalInstance = ModalSrv.confirm( + 'Disable MFA', + 'Are you sure you want to disabble MFA settings?', { + okText: 'Yes, disable it', + flavor: 'danger' + } + ); + + modalInstance.result + .then(function() { + UserSrv.resetMfa(); + }) + .then(function() { NotificationSrv.log('Your multi-factor authentication has been successfully disabled', 'success'); $state.reload(); - }) .catch(function(err) { - NotificationSrv.error('SettingsCtrl', err.data, err.status); + if (!_.isString(err)) { + NotificationSrv.error('SettingsCtrl', err.data, err.status); + } }); };