Do not require refreshToken during auth

This commit is contained in:
SleepWalker 2016-11-19 17:50:30 +02:00
parent 2653085f57
commit e4ccf8d193
4 changed files with 5 additions and 12 deletions

View File

@ -22,7 +22,7 @@ export default function accounts(
) { ) {
switch (type) { switch (type) {
case ADD: 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'); throw new Error('Invalid or empty payload passed for accounts.add');
} }
@ -41,7 +41,7 @@ export default function accounts(
return state; return state;
case ACTIVATE: 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'); throw new Error('Invalid or empty payload passed for accounts.add');
} }

View File

@ -62,10 +62,6 @@ const authentication = {
throw new Error('token must be a string'); throw new Error('token must be a string');
} }
if (typeof refreshToken !== 'string') {
throw new Error('refreshToken must be a string');
}
resolve(); resolve();
}) })
.then(() => accounts.current({token})) .then(() => accounts.current({token}))

View File

@ -10,8 +10,7 @@ const account = {
id: 1, id: 1,
username: 'username', username: 'username',
email: 'email@test.com', email: 'email@test.com',
token: 'foo', token: 'foo'
refreshToken: 'foo'
}; };
describe('Accounts reducer', () => { describe('Accounts reducer', () => {

View File

@ -37,10 +37,8 @@ describe('authentication api', () => {
) )
); );
it('rejects if refreshToken has a bad type', () => it('should allow empty refreshToken', () =>
expect(authentication.validateToken({token: 'foo', refreshToken: {}}), expect(authentication.validateToken({token: 'foo', refreshToken: null}), 'to be fulfilled')
'to be rejected with', 'refreshToken must be a string'
)
); );
it('rejects if accounts.current request is unexpectedly failed', () => { it('rejects if accounts.current request is unexpectedly failed', () => {