Fix auth guard user id extractor

main
MiguelMLorente 2025-12-06 23:05:12 +01:00
parent 8a590b42f2
commit 630c8b59be
1 changed files with 4 additions and 1 deletions

View File

@ -40,8 +40,11 @@ export class AuthGuard implements CanActivate {
const payload = await this.jwtService.verifyAsync(token, {
secret: this.jwtSecret,
});
if (!payload.userId) {
throw 'Unauthorised';
}
request['user'] = payload;
request['userId'] = payload.userId;
} catch {
throw new UnauthorizedException();
}