From 7e0b0a05de2052d1a480595018d23878e20e6f60 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Mon, 23 Jan 2017 17:04:34 +1300 Subject: [PATCH] feat(authentication): clean the state and the browser local storage on logout --- app/shared/services.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/shared/services.js b/app/shared/services.js index e1c671e85..b7c74196d 100644 --- a/app/shared/services.js +++ b/app/shared/services.js @@ -240,7 +240,7 @@ angular.module('portainer.services', ['ngResource', 'ngSanitize']) initAdminUser: { method: 'POST', params: { username: 'admin', action: 'init' } } }); }]) - .factory('Authentication', ['$q', '$rootScope', 'Auth', 'jwtHelper', 'LocalStorage', function AuthenticationFactory($q, $rootScope, Auth, jwtHelper, LocalStorage) { + .factory('Authentication', ['$q', '$rootScope', 'Auth', 'jwtHelper', 'LocalStorage', 'StateManager', function AuthenticationFactory($q, $rootScope, Auth, jwtHelper, LocalStorage, StateManager) { 'use strict'; return { init: function() { @@ -263,7 +263,8 @@ angular.module('portainer.services', ['ngResource', 'ngSanitize']) }); }, logout: function() { - LocalStorage.deleteJWT(); + StateManager.clean(); + LocalStorage.clean(); }, isAuthenticated: function() { var jwt = LocalStorage.getJWT(); @@ -343,6 +344,9 @@ angular.module('portainer.services', ['ngResource', 'ngSanitize']) }, deleteJWT: function() { localStorageService.remove('JWT'); + }, + clean: function() { + localStorageService.clearAll(); } }; }]) @@ -363,6 +367,9 @@ angular.module('portainer.services', ['ngResource', 'ngSanitize']) } state.loading = false; }, + clean: function() { + state.endpoint = {}; + }, updateEndpointState: function(loading) { var deferred = $q.defer(); if (loading) {