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) {
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');
}

View File

@ -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}))

View File

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

View File

@ -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', () => {