1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-25 08:19:40 +02:00

refactor(app): refactor unauthenticated state management (#2393)

* refactor(app): refactor Authentication service

* refactor(app): refactor unauthenticated state management
This commit is contained in:
Anthony Lapenna 2018-10-23 17:28:59 +13:00 committed by GitHub
parent 4f9a8180f9
commit b5dfaff292
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 42 deletions

View file

@ -37,9 +37,13 @@ function ($rootScope, $state, Authentication, authManager, StateManager, Endpoin
function initAuthentication(authManager, Authentication, $rootScope, $state) {
authManager.checkAuthOnRefresh();
authManager.redirectWhenUnauthenticated();
Authentication.init();
$rootScope.$on('tokenHasExpired', function() {
// The unauthenticated event is broadcasted by the jwtInterceptor when
// hitting a 401. We're using this instead of the usual combination of
// authManager.redirectWhenUnauthenticated() + unauthenticatedRedirector
// to have more controls on which URL should trigger the unauthenticated state.
$rootScope.$on('unauthenticated', function () {
$state.go('portainer.auth', {error: 'Your session has expired'});
});
}