feat(authentication): clean the state and the browser local storage on logout

pull/534/head
Anthony Lapenna 2017-01-23 17:04:34 +13:00
parent 980f65a08a
commit 7e0b0a05de
1 changed files with 9 additions and 2 deletions

View File

@ -240,7 +240,7 @@ angular.module('portainer.services', ['ngResource', 'ngSanitize'])
initAdminUser: { method: 'POST', params: { username: 'admin', action: 'init' } } 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'; 'use strict';
return { return {
init: function() { init: function() {
@ -263,7 +263,8 @@ angular.module('portainer.services', ['ngResource', 'ngSanitize'])
}); });
}, },
logout: function() { logout: function() {
LocalStorage.deleteJWT(); StateManager.clean();
LocalStorage.clean();
}, },
isAuthenticated: function() { isAuthenticated: function() {
var jwt = LocalStorage.getJWT(); var jwt = LocalStorage.getJWT();
@ -343,6 +344,9 @@ angular.module('portainer.services', ['ngResource', 'ngSanitize'])
}, },
deleteJWT: function() { deleteJWT: function() {
localStorageService.remove('JWT'); localStorageService.remove('JWT');
},
clean: function() {
localStorageService.clearAll();
} }
}; };
}]) }])
@ -363,6 +367,9 @@ angular.module('portainer.services', ['ngResource', 'ngSanitize'])
} }
state.loading = false; state.loading = false;
}, },
clean: function() {
state.endpoint = {};
},
updateEndpointState: function(loading) { updateEndpointState: function(loading) {
var deferred = $q.defer(); var deferred = $q.defer();
if (loading) { if (loading) {