2 changed files with 15 additions and 1 deletions
@ -0,0 +1,13 @@ |
|||
import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common'; |
|||
|
|||
@Injectable() |
|||
export class OnlyMeGuard implements CanActivate { |
|||
constructor() {} |
|||
|
|||
canActivate(context: ExecutionContext): boolean { |
|||
const request = context.switchToHttp().getRequest(); |
|||
const user = request.user; |
|||
|
|||
return request.params.id == user.sub; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue