mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-01-15 00:02:30 +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) {
|
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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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}))
|
||||||
|
@ -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', () => {
|
||||||
|
@ -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', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user