Skip to content

Commit

Permalink
don't invalidate a non-authenticated session, closes #185
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoow committed Jun 4, 2014
1 parent 2b07082 commit 07f2694
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ var ApplicationRouteMixin = Ember.Mixin.create({
@method actions.authorizationFailed
*/
authorizationFailed: function() {
this.get(Configuration.sessionPropertyName).invalidate();
if (this.get(Configuration.sessionPropertyName).get('isAuthenticated')) {
this.get(Configuration.sessionPropertyName).invalidate();
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,26 @@ describe('ApplicationRouteMixin', function() {
});

describe('the "authorizationFailed" action', function() {
it('invalidates the session', function() {
sinon.stub(this.session, 'invalidate').returns(Ember.RSVP.resolve());
this.route._actions.authorizationFailed.apply(this.route);
describe('when the session is authenticated', function() {
beforeEach(function() {
this.session.set('isAuthenticated', true);
});

expect(this.session.invalidate).to.have.been.calledOnce;
it('invalidates the session', function() {
sinon.stub(this.session, 'invalidate').returns(Ember.RSVP.resolve());
this.route._actions.authorizationFailed.apply(this.route);

expect(this.session.invalidate).to.have.been.calledOnce;
});
});

describe('when the session is not authenticated', function() {
it('does not try to invalidate the session', function() {
sinon.stub(this.session, 'invalidate').returns(Ember.RSVP.resolve());
this.route._actions.authorizationFailed.apply(this.route);

expect(this.session.invalidate).to.not.have.been.calledOnce;
});
});
});
});

0 comments on commit 07f2694

Please sign in to comment.