Skip to content

Commit

Permalink
Fix current user not set to null when logout request fail #401
Browse files Browse the repository at this point in the history
  • Loading branch information
inDream authored and carmenlau committed Apr 20, 2018
1 parent 86e677e commit 95e78cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/skygear-core/lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ export class AuthContainer {
]).then(() => null);
})
.catch((err) => {
return this._setAccessToken(null).then(() => {
return Promise.all([
this._setAccessToken(null),
this._setUser(null)
]).then(() => {
return Promise.reject(err);
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/skygear-core/test/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ describe('Container auth', function () {
/* eslint-enable-line camelcase */
});

it('should clear access token if logout fail', function () {
it('should clear current user and access token if logout fail', function () {
/* eslint-disable camelcase */
const aUserAttr = {
user_id: '68a2e6ce-9321-4561-8042-a8fa076e9214',
Expand Down Expand Up @@ -512,7 +512,7 @@ describe('Container auth', function () {
assert.equal(true, false);
}, () => {
assert.isNull(container.auth.accessToken);
assert.isNotNull(container.auth.currentUser);
assert.isNull(container.auth.currentUser);
});
/* eslint-enable-line camelcase */
});
Expand Down

0 comments on commit 95e78cc

Please sign in to comment.