diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index d2f322d40..194747949 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -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']}); diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 21d3de1a9..b6c15e3c2 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -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'); }); }); diff --git a/front/core/services/token.js b/front/core/services/token.js index f1408f7e3..c8cb4f6bb 100644 --- a/front/core/services/token.js +++ b/front/core/services/token.js @@ -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; });