Skip to content

Commit

Permalink
fix(security): ensure that login returns the correct value
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Oct 23, 2013
1 parent 481509d commit 38fcd56
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/src/common/security/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ angular.module('security.service', [
if ( service.isAuthenticated() ) {
closeLoginDialog(true);
}
return service.isAuthenticated();
});
},

Expand Down
14 changes: 14 additions & 0 deletions client/test/unit/common/security/security.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 38fcd56

Please sign in to comment.