Commit 2e188a0ce23e20315d58efa5bd3e4504717145ad
1 parent
8591c23c
Exists in
master
and in
38 other branches
Improve login/logout flow
Showing
3 changed files
with
14 additions
and
4 deletions
Show diff stats
gulp/server.js
... | ... | @@ -30,6 +30,7 @@ function browserSyncInit(baseDir, browser) { |
30 | 30 | proxyMiddleware('http://localhost:3000/myprofile', {changeOrigin:true}), |
31 | 31 | proxyMiddleware('http://localhost:3000/designs', {changeOrigin:true}), |
32 | 32 | proxyMiddleware('http://localhost:3000/image_uploads', {changeOrigin:true}), |
33 | + proxyMiddleware('http://localhost:3000/account/logout', {changeOrigin:true}), | |
33 | 34 | proxyMiddleware('http://localhost:3000/images', {changeOrigin:true})]; |
34 | 35 | // proxyMiddleware('http://localhost:3000/assets', {changeOrigin:true})]; |
35 | 36 | ... | ... |
src/app/components/auth/auth.service.js
src/app/components/navbar/navbar.directive.js
... | ... | @@ -27,21 +27,29 @@ |
27 | 27 | // "vm.creation" is avaible by directive option "bindToController: true" |
28 | 28 | vm.relativeDate = moment(vm.creationDate).fromNow(); |
29 | 29 | vm.currentUser = Session.getCurrentUser(); |
30 | + vm.modalInstance = null; | |
30 | 31 | |
31 | 32 | vm.openLogin = function() { |
32 | - var modalInstance = $modal.open({ | |
33 | + vm.modalInstance = $modal.open({ | |
33 | 34 | templateUrl: 'app/components/auth/login.html', |
34 | 35 | controller: 'AuthController', |
35 | 36 | controllerAs: 'vm', |
36 | 37 | bindToController: true |
37 | 38 | }); |
38 | - $scope.$on(AUTH_EVENTS.loginSuccess, function() { | |
39 | - modalInstance.close(); | |
40 | - }); | |
41 | 39 | }; |
42 | 40 | vm.logout = function() { |
43 | 41 | AuthService.logout(); |
44 | 42 | }; |
43 | + $scope.$on(AUTH_EVENTS.loginSuccess, function() { | |
44 | + if(vm.modalInstance) { | |
45 | + vm.modalInstance.close(); | |
46 | + vm.modalInstance = null; | |
47 | + } | |
48 | + vm.currentUser = Session.getCurrentUser(); | |
49 | + }); | |
50 | + $scope.$on(AUTH_EVENTS.logoutSuccess, function() { | |
51 | + vm.currentUser = Session.getCurrentUser(); | |
52 | + }); | |
45 | 53 | } |
46 | 54 | } |
47 | 55 | ... | ... |