diff --git a/client/src/common/security/security.js b/client/src/common/security/security.js index 81cb2e06..34bd3f15 100644 --- a/client/src/common/security/security.js +++ b/client/src/common/security/security.js @@ -65,6 +65,7 @@ angular.module('security.service', [ if ( service.isAuthenticated() ) { closeLoginDialog(true); } + return service.isAuthenticated(); }); }, diff --git a/client/test/unit/common/security/security.spec.js b/client/test/unit/common/security/security.spec.js index 34d88dae..62a6c5b4 100644 --- a/client/test/unit/common/security/security.spec.js +++ b/client/test/unit/common/security/security.spec.js @@ -58,6 +58,20 @@ describe('security', function() { $httpBackend.flush(); expect(queue.retryAll).not.toHaveBeenCalled(); }); + it('returns true to success handlers if the user authenticated', function() { + $httpBackend.when('POST', '/login').respond(200, { user: userInfo }); + service.login('email', 'password').then(function(loggedIn) { + expect(loggedIn).toBe(true); + }); + $httpBackend.flush(); + }); + it('returns true to success handlers if the user was not authenticated', function() { + $httpBackend.when('POST', '/login').respond(200, { user: undefined }); + service.login('email', 'password').then(function(loggedIn) { + expect(loggedIn).toBe(false); + }); + $httpBackend.flush(); + }); }); describe('logout', function() {