#6264 - renewToken #1824
|
@ -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)
|
||||
jsegarra marked this conversation as resolved
Outdated
|
||||
return token;
|
||||
|
||||
const {courtesyTime} = await models.AccessTokenConfig.findOne({fields: ['courtesyTime']});
|
||||
jsegarra marked this conversation as resolved
Outdated
juan
commented
Para que se selecciona Para que se selecciona `renewPeriod` si luego no se utiliza?
jsegarra
commented
Oh, tienes razón la línea venia heredada de otro sitio Oh, tienes razón la línea venia heredada de otro sitio
|
||||
|
||||
|
|
|
@ -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
El método validateToken solo se llama desde aquí en toda la aplicación, puede eliminarse y poner su código directamente aquí.
Era la idea, pero no la seguí porque había un remoteMethod de validateToken y asumí que si existía seria por algo y había que aprovecharlo.
Consideras que deberíamos mover la lógica de ese método a este y eliminarlo?
Si ves que sólo se llama desde aquí sí.