This repository has been archived by the owner on Apr 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Use access toke ngenerator abstraction
- Loading branch information
1 parent
527ab9a
commit 3e259b4
Showing
2 changed files
with
49 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common'; | ||
import { Reflector } from '@nestjs/core'; | ||
import { AccessTokenParsed } from './auth.interface'; | ||
|
||
@Injectable() | ||
export class ScopesGuard implements CanActivate { | ||
constructor(private reflector: Reflector) {} | ||
|
||
canActivate(context: ExecutionContext): boolean { | ||
const scopes = this.reflector.get<string[]>('scopes', context.getHandler()); | ||
console.log(scopes); | ||
if (!scopes) return true; | ||
const request = context.switchToHttp().getRequest(); | ||
const user: AccessTokenParsed = request.user; | ||
|
||
// return user.scopes.includes(scopes); | ||
} | ||
} |