Fix auth guard user id extractor
parent
8a590b42f2
commit
630c8b59be
|
|
@ -40,8 +40,11 @@ export class AuthGuard implements CanActivate {
|
||||||
const payload = await this.jwtService.verifyAsync(token, {
|
const payload = await this.jwtService.verifyAsync(token, {
|
||||||
secret: this.jwtSecret,
|
secret: this.jwtSecret,
|
||||||
});
|
});
|
||||||
|
if (!payload.userId) {
|
||||||
|
throw 'Unauthorised';
|
||||||
|
}
|
||||||
|
|
||||||
request['user'] = payload;
|
request['userId'] = payload.userId;
|
||||||
} catch {
|
} catch {
|
||||||
throw new UnauthorizedException();
|
throw new UnauthorizedException();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue