feat: add refresh token and global exception filter
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { RedisService } from '@/common/modules/redis/providers/redis.service';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class AuthRedisProvider {
|
||||
constructor(
|
||||
/**
|
||||
* Injecting Redis Service
|
||||
*/
|
||||
private readonly redisService: RedisService,
|
||||
) {}
|
||||
|
||||
async storeRefreshToken(jti: string, userId: number, ttl: number) {
|
||||
await this.redisService.set(`rt:${jti}`, userId.toString(), ttl);
|
||||
}
|
||||
|
||||
async hasRefreshToken(jti: string) {
|
||||
return !!(await this.redisService.get(`rt:${jti}`));
|
||||
}
|
||||
|
||||
async revokeRefreshToken(jti: string) {
|
||||
await this.redisService.del(`rt:${jti}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user