From e4ccf8d193e44424a06fbe461e81ba34a823dc37 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Sat, 19 Nov 2016 17:50:30 +0200 Subject: [PATCH] Do not require refreshToken during auth --- src/components/accounts/reducer.js | 4 ++-- src/services/api/authentication.js | 4 ---- tests/components/accounts/reducer.test.js | 3 +-- tests/services/api/authentication.test.js | 6 ++---- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/components/accounts/reducer.js b/src/components/accounts/reducer.js index 36d6eb4..173a895 100644 --- a/src/components/accounts/reducer.js +++ b/src/components/accounts/reducer.js @@ -22,7 +22,7 @@ export default function accounts( ) { switch (type) { case ADD: - if (!payload || !payload.id || !payload.token || !payload.refreshToken) { + if (!payload || !payload.id || !payload.token) { throw new Error('Invalid or empty payload passed for accounts.add'); } @@ -41,7 +41,7 @@ export default function accounts( return state; case ACTIVATE: - if (!payload || !payload.id || !payload.token || !payload.refreshToken) { + if (!payload || !payload.id || !payload.token) { throw new Error('Invalid or empty payload passed for accounts.add'); } diff --git a/src/services/api/authentication.js b/src/services/api/authentication.js index b495f5b..a9142b1 100644 --- a/src/services/api/authentication.js +++ b/src/services/api/authentication.js @@ -62,10 +62,6 @@ const authentication = { throw new Error('token must be a string'); } - if (typeof refreshToken !== 'string') { - throw new Error('refreshToken must be a string'); - } - resolve(); }) .then(() => accounts.current({token})) diff --git a/tests/components/accounts/reducer.test.js b/tests/components/accounts/reducer.test.js index 140766e..731860c 100644 --- a/tests/components/accounts/reducer.test.js +++ b/tests/components/accounts/reducer.test.js @@ -10,8 +10,7 @@ const account = { id: 1, username: 'username', email: 'email@test.com', - token: 'foo', - refreshToken: 'foo' + token: 'foo' }; describe('Accounts reducer', () => { diff --git a/tests/services/api/authentication.test.js b/tests/services/api/authentication.test.js index 6f054f9..95fcaec 100644 --- a/tests/services/api/authentication.test.js +++ b/tests/services/api/authentication.test.js @@ -37,10 +37,8 @@ describe('authentication api', () => { ) ); - it('rejects if refreshToken has a bad type', () => - expect(authentication.validateToken({token: 'foo', refreshToken: {}}), - 'to be rejected with', 'refreshToken must be a string' - ) + it('should allow empty refreshToken', () => + expect(authentication.validateToken({token: 'foo', refreshToken: null}), 'to be fulfilled') ); it('rejects if accounts.current request is unexpectedly failed', () => {