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.
|
// to have more controls on which URL should trigger the unauthenticated state.
|
||||||
$rootScope.$on('unauthenticated', function (event, data) {
|
$rootScope.$on('unauthenticated', function (event, data) {
|
||||||
if (!_.includes(data.config.url, '/v2/')) {
|
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 = {
|
var authentication = {
|
||||||
name: 'portainer.auth',
|
name: 'portainer.auth',
|
||||||
url: '/auth',
|
url: '/auth?redirect',
|
||||||
params: {
|
params: {
|
||||||
logout: false,
|
logout: false,
|
||||||
error: ''
|
error: ''
|
||||||
|
@ -87,7 +87,7 @@ angular.module('portainer.app', [])
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var endpointCreation = {
|
var endpointCreation = {
|
||||||
name: 'portainer.endpoints.new',
|
name: 'portainer.endpoints.new',
|
||||||
url: '/new',
|
url: '/new',
|
||||||
views: {
|
views: {
|
||||||
|
@ -242,7 +242,7 @@ angular.module('portainer.app', [])
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var registryCreation = {
|
var registryCreation = {
|
||||||
name: 'portainer.registries.new',
|
name: 'portainer.registries.new',
|
||||||
url: '/new',
|
url: '/new',
|
||||||
views: {
|
views: {
|
||||||
|
@ -286,7 +286,7 @@ angular.module('portainer.app', [])
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var scheduleCreation = {
|
var scheduleCreation = {
|
||||||
name: 'portainer.schedules.new',
|
name: 'portainer.schedules.new',
|
||||||
url: '/new',
|
url: '/new',
|
||||||
views: {
|
views: {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('portainer.app')
|
angular.module('portainer.app')
|
||||||
.controller('AuthenticationController', ['$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) {
|
function ($q, $scope, $state, $transition$, $sanitize, Authentication, UserService, EndpointService, StateManager, Notifications, SettingsService, $stateParams) {
|
||||||
|
|
||||||
$scope.logo = StateManager.getState().application.logo;
|
$scope.logo = StateManager.getState().application.logo;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ function ($q, $scope, $state, $transition$, $sanitize, Authentication, UserServi
|
||||||
if (endpoints.length === 0) {
|
if (endpoints.length === 0) {
|
||||||
$state.go('portainer.init.endpoint');
|
$state.go('portainer.init.endpoint');
|
||||||
} else {
|
} else {
|
||||||
$state.go('portainer.home');
|
$state.go($stateParams.redirect ||'portainer.home');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function error(err) {
|
.catch(function error(err) {
|
||||||
|
@ -73,7 +73,7 @@ function ($q, $scope, $state, $transition$, $sanitize, Authentication, UserServi
|
||||||
if (endpoints.length === 0 && userDetails.role === 1) {
|
if (endpoints.length === 0 && userDetails.role === 1) {
|
||||||
$state.go('portainer.init.endpoint');
|
$state.go('portainer.init.endpoint');
|
||||||
} else {
|
} else {
|
||||||
$state.go('portainer.home');
|
$state.go($stateParams.redirect || 'portainer.home');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function error(err) {
|
.catch(function error(err) {
|
||||||
|
|
Loading…
Reference in New Issue