Merging main into switching-user-module

This commit is contained in:
2025-11-16 09:27:49 -06:00
3 changed files with 16 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ import { ExecutionContext, Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core'; import { Reflector } from '@nestjs/core';
import { AuthGuard as PassportAuthGuard } from '@nestjs/passport'; import { AuthGuard as PassportAuthGuard } from '@nestjs/passport';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { IS_PUBLIC_KEY } from '../decorators/public.decorator';
@Injectable() @Injectable()
export class AuthGuard extends PassportAuthGuard('jwt') { export class AuthGuard extends PassportAuthGuard('jwt') {
@@ -10,6 +11,13 @@ export class AuthGuard extends PassportAuthGuard('jwt') {
} }
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean> { 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); 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'; export * from './util/customError';
// Decorators
export { IS_PUBLIC_KEY, Public } from './decorators/public.decorator'
// MsGraph // MsGraph
export * from './msgraph/msgraph.module'; export * from './msgraph/msgraph.module';