mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-27 15:30:37 +05:30
Do not require refreshToken during auth
This commit is contained in:
parent
2653085f57
commit
e4ccf8d193
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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}))
|
||||
|
@ -10,8 +10,7 @@ const account = {
|
||||
id: 1,
|
||||
username: 'username',
|
||||
email: 'email@test.com',
|
||||
token: 'foo',
|
||||
refreshToken: 'foo'
|
||||
token: 'foo'
|
||||
};
|
||||
|
||||
describe('Accounts reducer', () => {
|
||||
|
@ -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', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user