This commit is contained in:
2025-05-22 22:02:54 +07:00
parent 38d1bbf647
commit b2a4cd3f4f
5 changed files with 73 additions and 11 deletions

View File

@@ -34,6 +34,19 @@ export class UsersService {
throw new HttpException('User with this id does not exist', HttpStatus.NOT_FOUND);
}
async getUserIfRefreshTokenMatches(refreshToken: string, userId: number) {
const user = await this.getById(userId);
const isRefreshTokenMatching = await bcrypt.compare(
refreshToken,
user.currentHashedRefreshToken
);
if (isRefreshTokenMatching) {
return user;
}
}
async addAvatar(userId: number, imageBuffer: Buffer, filename: string) {
const avatar = await this.filesService.uploadPublicFile(imageBuffer, filename);
const user = await this.getById(userId);
@@ -62,5 +75,4 @@ export class UsersService {
currentHashedRefreshToken: null,
});
}
}