Skip to content
Snippets Groups Projects
Commit 2074e682 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

Merge pull request #1199 from metabase/redirect_after_login

Redirect back to page after logging in
parents 4ab78d2f aa5e9af3
No related branches found
No related tags found
No related merge requests found
......@@ -31,8 +31,7 @@ AuthControllers.controller('Login', ['$scope', '$location', '$timeout', 'AuthUti
// this is ridiculously stupid. we have to wait (300ms) for the cookie to actually be set in the browser :(
$timeout(function() {
// we expect the homepage to handle the routing details about where the user should be going
$location.path('/');
AppState.redirectAfterLogin();
}, 300);
}, function (error) {
$scope.$broadcast("form:api-error", error);
......
......@@ -22,7 +22,8 @@ MetabaseServices.factory('AppState', ['$rootScope', '$q', '$location', '$interva
model: {
setupToken: null,
currentUser: null,
appContext: 'none'
appContext: 'none',
requestedUrl: null
},
init: function() {
......@@ -157,8 +158,9 @@ MetabaseServices.factory('AppState', ['$rootScope', '$q', '$location', '$interva
service.clearState();
if ($location.path().indexOf('/auth/') !== 0 && $location.path().indexOf('/setup/') !== 0) {
// if the user is asking for a url outside of /auth/* then send them to login page
// otherwise we will let the user continue on to their requested page
// if the user is asking for a url outside of /auth/* then record the url then send them
// to login page, otherwise we will let the user continue on to their requested page
service.model.requestedUrl = $location.path();
$location.path('/auth/login');
}
......@@ -173,6 +175,15 @@ MetabaseServices.factory('AppState', ['$rootScope', '$q', '$location', '$interva
}
}
},
redirectAfterLogin: function() {
if (service.model.requestedUrl) {
$location.path(service.model.requestedUrl);
delete service.model.requestedUrl;
} else {
$location.path('/');
}
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment