mirror of
https://github.com/sismics/docs.git
synced 2024-11-25 15:17:57 +01:00
Closes #472: redirect to previous URL after login
This commit is contained in:
parent
bcb4c6d7b0
commit
1e0f8e2484
@ -356,7 +356,7 @@ angular.module('docs',
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('login', {
|
.state('login', {
|
||||||
url: '/login',
|
url: '/login?redirectState&redirectParams',
|
||||||
views: {
|
views: {
|
||||||
'page': {
|
'page': {
|
||||||
templateUrl: 'partial/docs/login.html',
|
templateUrl: 'partial/docs/login.html',
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/**
|
/**
|
||||||
* Login controller.
|
* Login controller.
|
||||||
*/
|
*/
|
||||||
angular.module('docs').controller('Login', function(Restangular, $scope, $rootScope, $state, $dialog, User, $translate, $uibModal) {
|
angular.module('docs').controller('Login', function(Restangular, $scope, $rootScope, $state, $stateParams, $dialog, User, $translate, $uibModal) {
|
||||||
$scope.codeRequired = false;
|
$scope.codeRequired = false;
|
||||||
|
|
||||||
// Get the app configuration
|
// Get the app configuration
|
||||||
@ -26,7 +26,14 @@ angular.module('docs').controller('Login', function(Restangular, $scope, $rootSc
|
|||||||
User.userInfo(true).then(function(data) {
|
User.userInfo(true).then(function(data) {
|
||||||
$rootScope.userInfo = data;
|
$rootScope.userInfo = data;
|
||||||
});
|
});
|
||||||
$state.go('document.default');
|
|
||||||
|
if($stateParams.redirectState !== undefined && $stateParams.redirectParams !== undefined) {
|
||||||
|
$state.go($stateParams.redirectState, JSON.parse($stateParams.redirectParams)).catch(function(){
|
||||||
|
$state.go('document.default');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$state.go('document.default');
|
||||||
|
}
|
||||||
}, function(data) {
|
}, function(data) {
|
||||||
if (data.data.type === 'ValidationCodeRequired') {
|
if (data.data.type === 'ValidationCodeRequired') {
|
||||||
// A TOTP validation code is required to login
|
// A TOTP validation code is required to login
|
||||||
|
@ -3,13 +3,18 @@
|
|||||||
/**
|
/**
|
||||||
* Navigation controller.
|
* Navigation controller.
|
||||||
*/
|
*/
|
||||||
angular.module('docs').controller('Navigation', function($scope, $state, $rootScope, User) {
|
angular.module('docs').controller('Navigation', function($scope, $state, $stateParams, $rootScope, User) {
|
||||||
User.userInfo().then(function(data) {
|
User.userInfo().then(function(data) {
|
||||||
$rootScope.userInfo = data;
|
$rootScope.userInfo = data;
|
||||||
if (data.anonymous) {
|
if (data.anonymous) {
|
||||||
$state.go('login', {}, {
|
if($state.current.name !== 'login') {
|
||||||
location: 'replace'
|
$state.go('login', {
|
||||||
});
|
redirectState: $state.current.name,
|
||||||
|
redirectParams: JSON.stringify($stateParams),
|
||||||
|
}, {
|
||||||
|
location: 'replace'
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user