MCPcopy Create free account
hub / github.com/bsoc-bitbyte/busify / validateAdmin

Method validateAdmin

backend/src/Auth/utils/admin.guard.ts:12–22  ·  view source on GitHub ↗
(userId: string)

Source from the content-addressed store, hash-verified

10export class AdminGuard implements CanActivate {
11 constructor(private prismaService: PrismaService) {}
12 async validateAdmin(userId: string) {
13 const user = await this.prismaService.users.findUnique({
14 where: {
15 id: userId,
16 },
17 });
18 if (user?.role === 'admin') {
19 return true;
20 }
21 return false;
22 }
23 async canActivate(context: ExecutionContext): Promise<boolean> {
24 const request = context.switchToHttp().getRequest();
25 const user = request.user;

Callers 1

canActivateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected