mirror of https://github.com/portainer/portainer
feat(auth): preserve url when redirected to login (#2591)
* feat(auth): preserve url when redirected to login * feat(auth): add redirect also to unauthenticated flow * style(app): remove style changes from files * fix(app): remove reference to otpLogin * style(auth): remove semicolonpull/2659/head
parent
8160fe4717
commit
f772cd31cb
|
@ -45,7 +45,7 @@ function initAuthentication(authManager, Authentication, $rootScope, $state) {
|
|||
// to have more controls on which URL should trigger the unauthenticated state.
|
||||
$rootScope.$on('unauthenticated', function (event, data) {
|
||||
if (!_.includes(data.config.url, '/v2/')) {
|
||||
$state.go('portainer.auth', {error: 'Your session has expired'});
|
||||
$state.go('portainer.auth', {error: 'Your session has expired', redirect: $state.current.name});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ angular.module('portainer.app', [])
|
|||
|
||||
var authentication = {
|
||||
name: 'portainer.auth',
|
||||
url: '/auth',
|
||||
url: '/auth?redirect',
|
||||
params: {
|
||||
logout: false,
|
||||
error: ''
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
angular.module('portainer.app')
|
||||
.controller('AuthenticationController', ['$q', '$scope', '$state', '$transition$', '$sanitize', 'Authentication', 'UserService', 'EndpointService', 'StateManager', 'Notifications', 'SettingsService',
|
||||
function ($q, $scope, $state, $transition$, $sanitize, Authentication, UserService, EndpointService, StateManager, Notifications, SettingsService) {
|
||||
.controller('AuthenticationController', ['$q', '$scope', '$state', '$transition$', '$sanitize', 'Authentication', 'UserService', 'EndpointService', 'StateManager', 'Notifications', 'SettingsService', '$stateParams',
|
||||
function ($q, $scope, $state, $transition$, $sanitize, Authentication, UserService, EndpointService, StateManager, Notifications, SettingsService, $stateParams) {
|
||||
|
||||
$scope.logo = StateManager.getState().application.logo;
|
||||
|
||||
|
@ -44,7 +44,7 @@ function ($q, $scope, $state, $transition$, $sanitize, Authentication, UserServi
|
|||
if (endpoints.length === 0) {
|
||||
$state.go('portainer.init.endpoint');
|
||||
} else {
|
||||
$state.go('portainer.home');
|
||||
$state.go($stateParams.redirect ||'portainer.home');
|
||||
}
|
||||
})
|
||||
.catch(function error(err) {
|
||||
|
@ -73,7 +73,7 @@ function ($q, $scope, $state, $transition$, $sanitize, Authentication, UserServi
|
|||
if (endpoints.length === 0 && userDetails.role === 1) {
|
||||
$state.go('portainer.init.endpoint');
|
||||
} else {
|
||||
$state.go('portainer.home');
|
||||
$state.go($stateParams.redirect || 'portainer.home');
|
||||
}
|
||||
})
|
||||
.catch(function error(err) {
|
||||
|
|
Loading…
Reference in New Issue