Merge pull request #843 from Gym/bug-previous-state

[Bug] Previous State (History)
This commit is contained in:
Liran Tal
2015-08-23 23:40:14 +03:00
3 changed files with 14 additions and 11 deletions

View File

@@ -35,11 +35,13 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(function ($ro
// Record previous state
$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
$state.previous = {
state: fromState,
params: fromParams,
href: $state.href(fromState, fromParams)
};
if (!fromState.data || !fromState.data.ignoreState) {
$state.previous = {
state: fromState,
params: fromParams,
href: $state.href(fromState, fromParams)
};
}
});
});

View File

@@ -15,7 +15,10 @@ angular.module('core').config(['$stateProvider', '$urlRouterProvider',
})
.state('not-found', {
url: '/not-found',
templateUrl: 'modules/core/client/views/404.client.view.html'
templateUrl: 'modules/core/client/views/404.client.view.html',
data: {
ignoreState: true
}
});
}
]);

View File

@@ -38,14 +38,12 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$stat
// OAuth provider request
$scope.callOauthProvider = function (url) {
var redirect_to;
if ($state.previous) {
redirect_to = $state.previous.href;
if ($state.previous && $state.previous.href) {
url += '?redirect_to=' + encodeURIComponent($state.previous.href);
}
// Effectively call OAuth authentication route:
$window.location.href = url + (redirect_to ? '?redirect_to=' + encodeURIComponent(redirect_to) : '');
$window.location.href = url;
};
}
]);