Merge pull request #932 from wknet123/dev-user-redirection

Fixed redirection when deleted user.
This commit is contained in:
kun wang 2016-10-25 13:41:54 +08:00 committed by GitHub
commit b39f3ec2fe

View File

@ -20,9 +20,9 @@
.module('harbor.session')
.controller('CurrentUserController', CurrentUserController);
CurrentUserController.$inject = ['$scope', 'CurrentUserService', 'currentUser', '$window', '$document'];
CurrentUserController.$inject = ['$scope', 'CurrentUserService', 'currentUser', '$window', '$document', 'LogOutService'];
function CurrentUserController($scope, CurrentUserService, currentUser, $window, $document) {
function CurrentUserController($scope, CurrentUserService, currentUser, $window, $document, LogOutService) {
var vm = this;
@ -32,16 +32,27 @@
function getCurrentUserComplete(response) {
if(angular.isDefined(response)) {
currentUser.set(response.data);
if(location.pathname === '/') {
currentUser.set(response.data);
if(location.pathname === '/') {
$window.location.href = '/dashboard';
}
}
}
function getCurrentUserFailed(e){
console.log('No session of current user.');
console.log('Failed to get current user:' + e);
LogOutService()
.success(logOutSuccess)
.error(logOutFailed);
}
function logOutSuccess(data, status) {
currentUser.unset();
}
function logOutFailed(data, status) {
console.log('Failed to log out:' + data);
}
}
})();