0
Fork 0
mirror of https://github.com/stonith404/pingvin-share.git synced 2025-01-15 01:14:27 -05:00

feat: add administrator guard

This commit is contained in:
Elias Schneider 2022-11-14 17:03:45 +01:00
parent 29b4a825d1
commit 13f98cc32c
2 changed files with 15 additions and 4 deletions

View file

@ -14,6 +14,7 @@ model User {
email String @unique
password String
isAdministrator Boolean @default(false)
firstName String?
lastName String?

View file

@ -0,0 +1,10 @@
import { CanActivate, ExecutionContext, Injectable } from "@nestjs/common";
import { User } from "@prisma/client";
@Injectable()
export class AdministratorGuard implements CanActivate {
canActivate(context: ExecutionContext): boolean {
const { user }: { user: User } = context.switchToHttp().getRequest();
return user.isAdministrator;
}
}