diff --git a/gulp/server.js b/gulp/server.js index 8a0ae69..aa4fb5f 100644 --- a/gulp/server.js +++ b/gulp/server.js @@ -30,6 +30,7 @@ function browserSyncInit(baseDir, browser) { proxyMiddleware('http://localhost:3000/myprofile', {changeOrigin:true}), proxyMiddleware('http://localhost:3000/designs', {changeOrigin:true}), proxyMiddleware('http://localhost:3000/image_uploads', {changeOrigin:true}), + proxyMiddleware('http://localhost:3000/account/logout', {changeOrigin:true}), proxyMiddleware('http://localhost:3000/images', {changeOrigin:true})]; // proxyMiddleware('http://localhost:3000/assets', {changeOrigin:true})]; diff --git a/src/app/components/auth/auth.service.js b/src/app/components/auth/auth.service.js index 04946b2..29837e1 100644 --- a/src/app/components/auth/auth.service.js +++ b/src/app/components/auth/auth.service.js @@ -36,6 +36,7 @@ } function logout () { + $http.jsonp('/account/logout'); //FIXME logout from noosfero to sync login state Session.destroy(); $rootScope.currentUser = undefined; $rootScope.$broadcast(AUTH_EVENTS.logoutSuccess); diff --git a/src/app/components/navbar/navbar.directive.js b/src/app/components/navbar/navbar.directive.js index 1c7348f..29aff94 100644 --- a/src/app/components/navbar/navbar.directive.js +++ b/src/app/components/navbar/navbar.directive.js @@ -27,21 +27,29 @@ // "vm.creation" is avaible by directive option "bindToController: true" vm.relativeDate = moment(vm.creationDate).fromNow(); vm.currentUser = Session.getCurrentUser(); + vm.modalInstance = null; vm.openLogin = function() { - var modalInstance = $modal.open({ + vm.modalInstance = $modal.open({ templateUrl: 'app/components/auth/login.html', controller: 'AuthController', controllerAs: 'vm', bindToController: true }); - $scope.$on(AUTH_EVENTS.loginSuccess, function() { - modalInstance.close(); - }); }; vm.logout = function() { AuthService.logout(); }; + $scope.$on(AUTH_EVENTS.loginSuccess, function() { + if(vm.modalInstance) { + vm.modalInstance.close(); + vm.modalInstance = null; + } + vm.currentUser = Session.getCurrentUser(); + }); + $scope.$on(AUTH_EVENTS.logoutSuccess, function() { + vm.currentUser = Session.getCurrentUser(); + }); } } -- libgit2 0.21.2