mirror of https://github.com/portainer/portainer
fix(auth): clear skips when using new instance [EE-3331] (#7027)
parent
8ed41de815
commit
212400c283
|
@ -49,6 +49,7 @@ function StateManagerFactory(
|
|||
};
|
||||
|
||||
manager.setPasswordChangeSkipped = function (userID) {
|
||||
state.UI.instanceId = state.UI.instanceId || state.application.instanceId;
|
||||
state.UI.timesPasswordChangeSkipped = state.UI.timesPasswordChangeSkipped || {};
|
||||
state.UI.timesPasswordChangeSkipped[userID] = state.UI.timesPasswordChangeSkipped[userID] + 1 || 1;
|
||||
LocalStorage.storeUIState(state.UI);
|
||||
|
@ -141,11 +142,6 @@ function StateManagerFactory(
|
|||
manager.initialize = initialize;
|
||||
async function initialize() {
|
||||
return $async(async () => {
|
||||
const UIState = LocalStorage.getUIState();
|
||||
if (UIState) {
|
||||
state.UI = UIState;
|
||||
}
|
||||
|
||||
const endpointState = LocalStorage.getEndpointState();
|
||||
if (endpointState) {
|
||||
state.endpoint = endpointState;
|
||||
|
@ -158,6 +154,16 @@ function StateManagerFactory(
|
|||
await loadApplicationState();
|
||||
}
|
||||
|
||||
const UIState = LocalStorage.getUIState();
|
||||
if (UIState) {
|
||||
state.UI = UIState;
|
||||
if (state.UI.instanceId && state.UI.instanceId !== state.application.instanceId) {
|
||||
state.UI.instanceId = state.application.instanceId;
|
||||
state.UI.timesPasswordChangeSkipped = {};
|
||||
LocalStorage.storeUIState(state.UI);
|
||||
}
|
||||
}
|
||||
|
||||
state.loading = false;
|
||||
$analytics.setPortainerStatus(state.application.instanceId, state.application.version);
|
||||
$analytics.setOptOut(!state.application.enableTelemetry);
|
||||
|
|
|
@ -22,7 +22,7 @@ angular.module('portainer.app').controller('AccountController', [
|
|||
try {
|
||||
await UserService.updateUserPassword($scope.userID, $scope.formValues.currentPassword, $scope.formValues.newPassword);
|
||||
Notifications.success('Success', 'Password successfully updated');
|
||||
StateManager.resetPasswordChangeSkips($scope.userID);
|
||||
StateManager.resetPasswordChangeSkips($scope.userID.toString());
|
||||
$scope.forceChangePassword = false;
|
||||
$state.go('portainer.logout');
|
||||
} catch (err) {
|
||||
|
@ -34,7 +34,7 @@ angular.module('portainer.app').controller('AccountController', [
|
|||
$scope.skipPasswordChange = async function () {
|
||||
try {
|
||||
if ($scope.userCanSkip()) {
|
||||
StateManager.setPasswordChangeSkipped($scope.userID);
|
||||
StateManager.setPasswordChangeSkipped($scope.userID.toString());
|
||||
$scope.forceChangePassword = false;
|
||||
$state.go('portainer.home');
|
||||
}
|
||||
|
@ -130,11 +130,13 @@ angular.module('portainer.app').controller('AccountController', [
|
|||
$scope.AuthenticationMethod = data.AuthenticationMethod;
|
||||
|
||||
if (state.UI.requiredPasswordLength && state.UI.requiredPasswordLength !== data.RequiredPasswordLength) {
|
||||
StateManager.clearPasswordChangeSkips($scope.userID);
|
||||
StateManager.clearPasswordChangeSkips($scope.userID.toString());
|
||||
}
|
||||
|
||||
$scope.timesPasswordChangeSkipped =
|
||||
state.UI.timesPasswordChangeSkipped && state.UI.timesPasswordChangeSkipped[$scope.userID] ? state.UI.timesPasswordChangeSkipped[$scope.userID] : 0;
|
||||
state.UI.timesPasswordChangeSkipped && state.UI.timesPasswordChangeSkipped[$scope.userID.toString()]
|
||||
? state.UI.timesPasswordChangeSkipped[$scope.userID.toString()]
|
||||
: 0;
|
||||
|
||||
$scope.requiredPasswordLength = data.RequiredPasswordLength;
|
||||
StateManager.setRequiredPasswordLength(data.RequiredPasswordLength);
|
||||
|
|
Loading…
Reference in New Issue