switching user module to msgraph module #15

Merged
noahspannbauer merged 2 commits from switching-user-module into main 2025-11-16 10:28:06 -05:00
3 changed files with 16 additions and 0 deletions
Showing only changes of commit dc860ee4c4 - Show all commits

View File

@@ -2,6 +2,7 @@ import { ExecutionContext, Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { AuthGuard as PassportAuthGuard } from '@nestjs/passport';
import { Observable } from 'rxjs';
import { IS_PUBLIC_KEY } from '../decorators/public.decorator';
@Injectable()
export class AuthGuard extends PassportAuthGuard('jwt') {
@@ -10,6 +11,13 @@ export class AuthGuard extends PassportAuthGuard('jwt') {
}
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean> {
const isPublic = this.reflector.get<boolean>(
IS_PUBLIC_KEY,
context.getHandler()
)
if (isPublic) return true;
return super.canActivate(context);
}
}

View File

@@ -0,0 +1,4 @@
import { SetMetadata } from "@nestjs/common";
export const IS_PUBLIC_KEY = "isPublic";
export const Public = () => SetMetadata(IS_PUBLIC_KEY, true);

View File

@@ -7,6 +7,10 @@ export * from './auth/auth.guard';
export * from './util/customError';
// Decorators
export { IS_PUBLIC_KEY, Public } from './decorators/public.decorator'
// MsGraph
export * from './msgraph/msgraph.module';