From 80f0e5437c237d4a3187b2e6c69632fcf5f5e24c Mon Sep 17 00:00:00 2001 From: Noah Spannbauer Date: Mon, 24 Feb 2025 19:53:18 -0600 Subject: [PATCH] fixing logbook non authenticated --- api/src/pilot/interceptors/pilot.interceptor.ts | 9 ++------- api/src/pilot/pilot.controller.ts | 8 ++++++-- app/src/components/logForm/LogForm.tsx | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/api/src/pilot/interceptors/pilot.interceptor.ts b/api/src/pilot/interceptors/pilot.interceptor.ts index 8a8362b..4a77af6 100644 --- a/api/src/pilot/interceptors/pilot.interceptor.ts +++ b/api/src/pilot/interceptors/pilot.interceptor.ts @@ -19,15 +19,10 @@ export class PilotInterceptor implements NestInterceptor { name: pilot.name }; }); - + console.log(pilots) return pilots; } else { - return { - partitionKey: data.partitionKey, - rowKey: data.rowKey, - id: data.id, - name: data.name - }; + return data; } }) ); diff --git a/api/src/pilot/pilot.controller.ts b/api/src/pilot/pilot.controller.ts index 4b3b432..d255163 100644 --- a/api/src/pilot/pilot.controller.ts +++ b/api/src/pilot/pilot.controller.ts @@ -7,18 +7,21 @@ import { Param, Post, Put, - UseGuards, + UseInterceptors, } from '@nestjs/common'; import { PilotDto } from './pilot.dto'; import { Pilot } from './pilot.entity'; import { PilotService } from './pilot.service'; import { CustomError } from '../error/customError'; -import { AuthGuard } from '@nestjs/passport' +import { Public } from '@noahspan/noahspan-modules' +import { PilotInterceptor } from './interceptors/pilot.interceptor'; @Controller('pilots') +@UseInterceptors(new PilotInterceptor()) export class PilotController { constructor(private readonly pilotService: PilotService) {} + @Public() @Get(':partitionKey/:rowKey') async find( @Param('partitionKey') partitionKey: string, @@ -33,6 +36,7 @@ export class PilotController { } } + @Public() @Get() async findAll() { try { diff --git a/app/src/components/logForm/LogForm.tsx b/app/src/components/logForm/LogForm.tsx index 59c38e8..711d234 100644 --- a/app/src/components/logForm/LogForm.tsx +++ b/app/src/components/logForm/LogForm.tsx @@ -122,7 +122,7 @@ const LogForm: React.FC = ({ config ); const entry = response.data; - console.log(entry) + methods.reset(entry); } catch (error) { const axiosError = error as AxiosError; @@ -139,7 +139,7 @@ const LogForm: React.FC = ({ }, [entryId]); useEffect(() => { - if (pilots) { + if (pilots && FormMode.ADD) { const newPilotsOptions = pilots.map((pilot) => { return { label: pilot.name,