fix: handle expired session error in auth flow and remove unused cache update

This commit is contained in:
sheldon guo 2025-02-13 16:30:28 +08:00
parent 2137af619d
commit e2b7c5109e
2 changed files with 7 additions and 1 deletions

View File

@ -173,6 +173,13 @@ export class BaseAuth extends Auth {
});
}
if (!jti) {
this.ctx.throw(401, {
message: this.ctx.t('Your session has expired. Please sign in again.', { ns: localeNamespace }),
code: AuthErrorCode.INVALID_TOKEN,
});
}
const renewedResult = await this.tokenController.renew(jti);
this.ctx.logger.info('token renewed', {
method: 'auth.check',

View File

@ -41,7 +41,6 @@ export class TokenController implements TokenControlService {
async setTokenInfo(id: string, value: TokenInfo): Promise<void> {
const repo = this.app.db.getRepository<Repository<TokenInfo>>(issuedTokensCollectionName);
await repo.updateOrCreate({ filterKeys: ['id'], values: value });
await this.cache.set(`${JTICACHEKEY}:${id}`, value);
return;
}