From debf4827656bd015582b24e94a1c6a29e9d55009 Mon Sep 17 00:00:00 2001 From: kunw Date: Tue, 25 Oct 2016 11:55:27 +0800 Subject: [PATCH] Fixed redirection when deleted user. --- .../js/session/session.current-user.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ui/static/resources/js/session/session.current-user.js b/src/ui/static/resources/js/session/session.current-user.js index 9e51af4cd..d4c3b6373 100644 --- a/src/ui/static/resources/js/session/session.current-user.js +++ b/src/ui/static/resources/js/session/session.current-user.js @@ -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,8 +32,8 @@ 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'; } } @@ -41,7 +41,18 @@ function getCurrentUserFailed(e){ console.log('No session of current user.'); + LogOutService() + .success(logOutSuccess) + .error(logOutFailed); } + + function logOutSuccess(data, status) { + currentUser.unset(); + } + + function logOutFailed(data, status) { + console.log('Failed to log out:' + data); + } } })(); \ No newline at end of file