mirror of https://github.com/portainer/portainer
fix(auth): switch to log-in when user is not logged in (#4162)
* fix(auth): switch to log-in when user is not logged in * fix(app): remove analytics injectionpull/4195/head
parent
a3925c3371
commit
8629738e34
|
@ -12,7 +12,7 @@ async function initAuthentication(authManager, Authentication, $rootScope, $stat
|
|||
}
|
||||
});
|
||||
|
||||
await Authentication.init();
|
||||
return await Authentication.init();
|
||||
}
|
||||
|
||||
angular.module('portainer.app', ['portainer.oauth']).config([
|
||||
|
@ -24,34 +24,23 @@ angular.module('portainer.app', ['portainer.oauth']).config([
|
|||
name: 'root',
|
||||
abstract: true,
|
||||
resolve: {
|
||||
initStateManager: [
|
||||
'StateManager',
|
||||
'Authentication',
|
||||
'Notifications',
|
||||
'authManager',
|
||||
'$rootScope',
|
||||
'$state',
|
||||
'$async',
|
||||
'$q',
|
||||
(StateManager, Authentication, Notifications, authManager, $rootScope, $state, $async, $q) => {
|
||||
const deferred = $q.defer();
|
||||
initStateManager: /* @ngInject */ function initStateManager($async, StateManager, Authentication, Notifications, authManager, $rootScope, $state) {
|
||||
return $async(async () => {
|
||||
const appState = StateManager.getState();
|
||||
if (!appState.loading) {
|
||||
deferred.resolve();
|
||||
} else {
|
||||
StateManager.initialize()
|
||||
.then(function success() {
|
||||
return $async(initAuthentication, authManager, Authentication, $rootScope, $state);
|
||||
})
|
||||
.then(() => deferred.resolve())
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to retrieve application settings');
|
||||
deferred.reject(err);
|
||||
});
|
||||
return;
|
||||
}
|
||||
return deferred.promise;
|
||||
},
|
||||
],
|
||||
try {
|
||||
const loggedIn = await initAuthentication(authManager, Authentication, $rootScope, $state);
|
||||
await StateManager.initialize();
|
||||
if (!loggedIn) {
|
||||
$state.go('portainer.auth');
|
||||
}
|
||||
} catch (err) {
|
||||
Notifications.error('Failure', err, 'Unable to retrieve application settings');
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
views: {
|
||||
'sidebar@': {
|
||||
|
|
|
@ -29,6 +29,7 @@ angular.module('portainer.app').factory('Authentication', [
|
|||
if (jwt) {
|
||||
await setUser(jwt);
|
||||
}
|
||||
return !!jwt;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue