fix(auth): clean browser cache on logout (#3402)

pull/3403/head
xAt0mZ 2019-11-28 00:16:34 +01:00 committed by Anthony Lapenna
parent e19bc8abc7
commit ea1ca76f70
2 changed files with 15 additions and 4 deletions

View File

@ -125,6 +125,9 @@ angular.module('portainer.app')
getJobImage: function() {
return localStorageService.get('job_image');
},
storeLogoutReason: (reason) => localStorageService.set('logout_reason', reason),
getLogoutReason: () => localStorageService.get('logout_reason'),
cleanLogoutReason: () => localStorageService.remove('logout_reason'),
clean: function() {
localStorageService.clearAll();
}

View File

@ -3,11 +3,12 @@ import uuidv4 from 'uuid/v4';
class AuthenticationController {
/* @ngInject */
constructor($async, $scope, $state, $stateParams, $sanitize, Authentication, UserService, EndpointService, ExtensionService, StateManager, Notifications, SettingsService, URLHelper, LocalStorage, StatusService) {
constructor($async, $scope, $state, $stateParams, $sanitize, $window, Authentication, UserService, EndpointService, ExtensionService, StateManager, Notifications, SettingsService, URLHelper, LocalStorage, StatusService) {
this.$async = $async;
this.$scope = $scope;
this.$state = $state;
this.$stateParams = $stateParams;
this.$window = $window;
this.$sanitize = $sanitize;
this.Authentication = Authentication;
this.UserService = UserService;
@ -51,10 +52,12 @@ class AuthenticationController {
* UTILS FUNCTIONS SECTION
*/
logout() {
logout(error) {
this.Authentication.logout();
this.state.loginInProgress = false;
this.generateOAuthLoginURI();
this.LocalStorage.storeLogoutReason(error);
this.$window.location.reload();
}
error(err, message) {
@ -250,8 +253,13 @@ class AuthenticationController {
this.generateOAuthLoginURI();
if (this.$stateParams.logout || this.$stateParams.error) {
this.logout();
this.state.AuthenticationError = this.$stateParams.error;
this.logout(this.$stateParams.error);
return;
}
const error = this.LocalStorage.getLogoutReason();
if (error) {
this.state.AuthenticationError = error;
this.LocalStorage.cleanLogoutReason();
}
if (this.Authentication.isAuthenticated()) {