removing public decorator
This commit is contained in:
@@ -1,25 +1,14 @@
|
||||
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 './public.decorator';
|
||||
|
||||
@Injectable()
|
||||
export class AuthGuard extends PassportAuthGuard('azure-ad') {
|
||||
constructor(private readonly reflector: Reflector) {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean> {
|
||||
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
|
||||
context.getHandler(),
|
||||
context.getClass()
|
||||
])
|
||||
|
||||
if (isPublic) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.canActivate(context);
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import {
|
||||
Headers,
|
||||
Query,
|
||||
StreamableFile,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { UserService } from './user.service';
|
||||
import { Client as MsGraphClient } from '@microsoft/microsoft-graph-client';
|
||||
import { AuthGuard } from '../auth/auth.gaurd';
|
||||
|
||||
@Controller('user')
|
||||
export class UserController {
|
||||
@@ -15,6 +17,7 @@ export class UserController {
|
||||
) {}
|
||||
|
||||
@Get('photo')
|
||||
@UseGuards(AuthGuard)
|
||||
async getProfilePhoto(@Headers() headers: any): Promise<StreamableFile> {
|
||||
try {
|
||||
const graphToken: string = await this.userService.getMsGraphAuth(
|
||||
@@ -37,6 +40,7 @@ export class UserController {
|
||||
}
|
||||
|
||||
@Get('profile')
|
||||
@UseGuards(AuthGuard)
|
||||
async getUserProfile(@Headers() headers: any): Promise<any> {
|
||||
try {
|
||||
const graphToken: string = await this.userService.getMsGraphAuth(
|
||||
@@ -54,6 +58,7 @@ export class UserController {
|
||||
}
|
||||
|
||||
@Get('search')
|
||||
@UseGuards(AuthGuard)
|
||||
async searchUsers(
|
||||
@Headers() headers: any,
|
||||
@Query('search') search: any
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@noahspan/noahspan-modules",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.5",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"license": "UNLICENSED",
|
||||
|
||||
Reference in New Issue
Block a user