mandatory 2fa: redirect if the browser URL is changed directly

This commit is contained in:
Girish Ramakrishnan
2022-08-16 10:01:05 +02:00
parent 4a2161d2b3
commit b3cdcb2adb

View File

@@ -76,6 +76,17 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
refreshNotifications();
};
function redirectOnMandatory2FA() {
if (Client.getConfig().mandatory2FA && !Client.getUserInfo().twoFactorAuthenticationEnabled) {
$location.path('/profile').search({ setup2fa: true });
}
}
// Make it redirect if the browser URL is changed directly - https://forum.cloudron.io/topic/7510/bug-in-2fa-force
$scope.$on('$routeChangeStart', function (/* event */) {
if ($scope.initialized) redirectOnMandatory2FA();
});
function init() {
Client.getStatus(function (error, status) {
if (error) return Client.initError(error, init);
@@ -138,10 +149,7 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
$scope.initialized = true;
if (Client.getConfig().mandatory2FA && !Client.getUserInfo().twoFactorAuthenticationEnabled) {
$location.path('/profile').search({ setup2fa: true });
return;
}
redirectOnMandatory2FA();
$interval(refreshNotifications, 60 * 1000);
refreshNotifications();