#6264 - renewToken #1824

Merged
jsegarra merged 36 commits from 6264-renewToken into dev 2023-12-20 09:22:29 +00:00
3 changed files with 7 additions and 10 deletions
Showing only changes of commit 8d29850917 - Show all commits

View File

@ -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
Outdated
Review

El método validateToken solo se llama desde aquí en toda la aplicación, puede eliminarse y poner su código directamente aquí.

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?

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í.

Si ves que sólo se llama desde aquí sí.
return token;
const {courtesyTime} = await models.AccessTokenConfig.findOne({fields: ['courtesyTime']});
jsegarra marked this conversation as resolved Outdated
Outdated
Review

Para que se selecciona renewPeriod si luego no se utiliza?

Para que se selecciona `renewPeriod` si luego no se utiliza?

Oh, tienes razón la línea venia heredada de otro sitio

Oh, tienes razón la línea venia heredada de otro sitio

View File

@ -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');
});
});

View File

@ -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;
});