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([
|
angular.module('portainer.app', ['portainer.oauth']).config([
|
||||||
|
@ -24,34 +24,23 @@ angular.module('portainer.app', ['portainer.oauth']).config([
|
||||||
name: 'root',
|
name: 'root',
|
||||||
abstract: true,
|
abstract: true,
|
||||||
resolve: {
|
resolve: {
|
||||||
initStateManager: [
|
initStateManager: /* @ngInject */ function initStateManager($async, StateManager, Authentication, Notifications, authManager, $rootScope, $state) {
|
||||||
'StateManager',
|
return $async(async () => {
|
||||||
'Authentication',
|
|
||||||
'Notifications',
|
|
||||||
'authManager',
|
|
||||||
'$rootScope',
|
|
||||||
'$state',
|
|
||||||
'$async',
|
|
||||||
'$q',
|
|
||||||
(StateManager, Authentication, Notifications, authManager, $rootScope, $state, $async, $q) => {
|
|
||||||
const deferred = $q.defer();
|
|
||||||
const appState = StateManager.getState();
|
const appState = StateManager.getState();
|
||||||
if (!appState.loading) {
|
if (!appState.loading) {
|
||||||
deferred.resolve();
|
return;
|
||||||
} 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 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: {
|
views: {
|
||||||
'sidebar@': {
|
'sidebar@': {
|
||||||
|
|
|
@ -29,6 +29,7 @@ angular.module('portainer.app').factory('Authentication', [
|
||||||
if (jwt) {
|
if (jwt) {
|
||||||
await setUser(jwt);
|
await setUser(jwt);
|
||||||
}
|
}
|
||||||
|
return !!jwt;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue