mandatory2fa: fix workflow when using external LDAP

* Always allow the mandatory 2fa setting to be saved
* Show warning for user if they have no 2fa setup and if not external 2fa
* If they get locked out anyway, they have to use CLI tool
* redirect for mandatory 2fa only if not external 2fa as well
This commit is contained in:
Girish Ramakrishnan
2024-05-25 12:54:40 +02:00
parent 077f95049e
commit d34b102e52
8 changed files with 27 additions and 10 deletions

View File

@@ -44,9 +44,6 @@ angular.module('Application').controller('UserSettingsController', ['$scope', '$
},
submit: function () {
// prevent the current user from getting locked out
if ($scope.profileConfig.mandatory2FA && !$scope.userInfo.twoFactorAuthenticationEnabled) return Client.notify('', $translate.instant('users.settings.require2FAWarning'), true, 'error', '#/profile');
$scope.profileConfig.error = '';
$scope.profileConfig.busy = true;
$scope.profileConfig.success = false;
@@ -68,6 +65,12 @@ angular.module('Application').controller('UserSettingsController', ['$scope', '$
$timeout(function () {
$scope.profileConfig.busy = false;
// prevent the current user from getting locked out. if user ignores this, they have to use cloudron-support --admin-login
if ($scope.profileConfig.mandatory2FA && !$scope.userInfo.twoFactorAuthenticationEnabled) {
if ($scope.userInfo.source && $scope.config.external2FA) return; // no need for warning if 2fa is external
Client.notify('', $translate.instant('users.settings.require2FAWarning'), true, 'error', '#/profile');
}
}, 500);
});
}