Fixes U4-5213 in a better way using a query string so it's clear where it redirects to
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
app.run(['userService', '$log', '$rootScope', '$location', 'navigationService', 'appState', 'editorState', 'fileManager', 'assetsService', 'eventsService', '$cookies', '$templateCache',
|
||||
function (userService, $log, $rootScope, $location, navigationService, appState, editorState, fileManager, assetsService, eventsService, $cookies, $templateCache) {
|
||||
|
||||
|
||||
//This sets the default jquery ajax headers to include our csrf token, we
|
||||
// need to user the beforeSend method because our token changes per user/login so
|
||||
// it cannot be static
|
||||
@@ -16,8 +15,10 @@ app.run(['userService', '$log', '$rootScope', '$location', 'navigationService',
|
||||
eventsService.on("app.authenticated", function(evt, data) {
|
||||
assetsService._loadInitAssets().then(function() {
|
||||
appState.setGlobalState("isReady", true);
|
||||
//send the ready event
|
||||
|
||||
//send the ready event with the included returnToPath,returnToSearch data
|
||||
eventsService.emit("app.ready", data);
|
||||
returnToPath = null, returnToSearch = null;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -44,9 +45,11 @@ app.run(['userService', '$log', '$rootScope', '$location', 'navigationService',
|
||||
wiring up it's controller, etc... and then redirect to the rejected URL. */
|
||||
$rootScope.$on('$routeChangeError', function(event, current, previous, rejection) {
|
||||
event.preventDefault();
|
||||
$rootScope.returnToPath = $location.$$path;
|
||||
$rootScope.returnToSearch = $location.$$search;
|
||||
$location.path(rejection.path).search(rejection.search);
|
||||
|
||||
//Set the current path before redirecting so we know where to redirect back to
|
||||
var returnPath = encodeURIComponent($location.url());
|
||||
|
||||
$location.path(rejection.path).search("returnPath", returnPath);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -3,8 +3,22 @@ angular.module('umbraco').controller("Umbraco.LoginController", function (events
|
||||
|
||||
userService._showLoginDialog();
|
||||
|
||||
eventsService.on("app.ready", function(){
|
||||
$scope.avatar = "assets/img/application/logo.png";
|
||||
$location.path($rootScope.returnToPath || "/").search($rootScope.returnToSearch || "");
|
||||
var evtOn = eventsService.on("app.ready", function(evt, data){
|
||||
$scope.avatar = "assets/img/application/logo.png";
|
||||
|
||||
var path = "/";
|
||||
|
||||
//check if there's a returnPath query string, if so redirect to it
|
||||
var locationObj = $location.search();
|
||||
if (locationObj.returnPath) {
|
||||
path = decodeURIComponent(locationObj.returnPath);
|
||||
}
|
||||
|
||||
$location.url(path);
|
||||
});
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
eventsService.unsubscribe(evtOn);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user