refs #6264 perf: remove UserError exception
This commit is contained in:
parent
61a323078b
commit
8d29850917
|
@ -29,7 +29,8 @@ module.exports = Self => {
|
|||
|
||||
// Check if current token is valid
|
||||
const isValid = await validateToken(token);
|
||||
if (isValid) throw new UserError(`The renew period has not been exceeded`, 'periodNotExceeded');
|
||||
if (isValid)
|
||||
return token;
|
||||
|
||||
const {courtesyTime} = await models.AccessTokenConfig.findOne({fields: ['courtesyTime']});
|
||||
|
||||
|
|
|
@ -37,13 +37,13 @@ describe('Renew Token', () => {
|
|||
it('NOT should renew', async() => {
|
||||
let error;
|
||||
try {
|
||||
await models.VnUser.renewToken(ctx);
|
||||
const response = await models.VnUser.renewToken(ctx);
|
||||
|
||||
expect(error).toBeUnDefined();
|
||||
expect(error.statusCode).toBe(200);
|
||||
expect(response.token.id).toEqual(ctx.req.accessToken.id);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toBeDefined();
|
||||
expect(error.statusCode).toBe(400);
|
||||
expect(error.message).toEqual('The renew period has not been exceeded');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -103,10 +103,6 @@ export default class Token {
|
|||
const token = res.data;
|
||||
this.set(token.id, now, token.ttl, this.remember);
|
||||
})
|
||||
.catch(res => {
|
||||
if (res.data?.error?.code !== 'periodNotExceeded')
|
||||
throw res;
|
||||
})
|
||||
.finally(() => {
|
||||
this.checking = false;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue