From 42dd32eed4172219066a3afbdc10b32b2daee0c4 Mon Sep 17 00:00:00 2001 From: Trenten Vollmer Date: Tue, 12 Nov 2024 15:14:40 -0500 Subject: [PATCH 1/2] fix: redid email verification endpoint fix: corrected api prefix --- .../src/auth/controllers/auth.controller.ts | 34 +++++-------------- apps/backend/src/main.ts | 9 +---- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/apps/backend/src/auth/controllers/auth.controller.ts b/apps/backend/src/auth/controllers/auth.controller.ts index ee137b0..6e2abb3 100644 --- a/apps/backend/src/auth/controllers/auth.controller.ts +++ b/apps/backend/src/auth/controllers/auth.controller.ts @@ -1,12 +1,10 @@ -import { Body, Controller, Get, Post, Query, Render, Req, Res, UseGuards } from '@nestjs/common'; -import { ApiExcludeEndpoint, ApiResponse, ApiTags } from '@nestjs/swagger'; +import { Body, Controller, Get, Post, Query, Req, Res } from '@nestjs/common'; +import { ApiTags } from '@nestjs/swagger'; import { AuthService } from '../services/auth.service'; import { ForgotPasswordDto } from '../dto/forgotPassword.dto'; import { CreateUserDto } from '../dto/register.dto'; import { LoginUserDto } from '../dto/loginUser.dto'; -import { CurrentUser } from '../decorators/user.decorator'; -import { ViewLoginGuard } from '../guard/viewLogin.guard'; import { Response, Request } from 'express'; import { LoginResponse } from '../dto/loginResponse.dto'; @@ -48,34 +46,18 @@ export class AuthController { return await this.authService.sendVerificationEmail(body.email); } - // ==== Render pages ==== // - @Get('verify-email') - @UseGuards(ViewLoginGuard) - @ApiExcludeEndpoint() - public async verifyEmail(@Res() response: Response, @Query('code') code: string): Promise { + public async verifyEmail(@Query('code') code: string): Promise { if (!code) { - return response.render('base/error', { - error_header: 'Invalid Verification Code', - error_message: - 'The verification code provided is invalid. Please try sending your verification email again.', - button_name: 'Go Back to Login', - button_link: '/api/v1/auth/login', - }); + return { error: true, message: 'Invalid Verification Code' }; } try { await this.authService.markEmailVerified(code); - } catch (e) { - return response.render('base/error', { - error_header: 'Invalid Verification Code', - error_message: - 'The verification code provided is invalid. Please try sending your verification email again.', - button_name: 'Go Back to Login', - button_link: 'api/v1/auth/login', - }); - } - response.redirect('/auth/login'); + return { error: false, message: 'Email Verified' }; + } catch (e) { + return { error: true, message: 'Invalid Verification Code' }; + } } } diff --git a/apps/backend/src/main.ts b/apps/backend/src/main.ts index 5084819..7ab223c 100644 --- a/apps/backend/src/main.ts +++ b/apps/backend/src/main.ts @@ -14,14 +14,7 @@ async function bootstrap() { app.disable('x-powered-by'); app.setGlobalPrefix('api', { - exclude: [ - { path: 'auth/login', method: RequestMethod.GET }, - { path: '', method: RequestMethod.GET }, - { path: 'auth/login/totp', method: RequestMethod.GET }, - { path: 'auth/forgot-password', method: RequestMethod.GET }, - { path: ':oidc*', method: RequestMethod.ALL }, - { path: ':interaction*', method: RequestMethod.ALL }, - ], + exclude: [{ path: 'oidc/:splat*', method: RequestMethod.ALL }], }); app.enableVersioning({ From 577df13f169eb2c524e48a77d155904cea3f7650 Mon Sep 17 00:00:00 2001 From: Trenten Vollmer Date: Tue, 12 Nov 2024 15:19:23 -0500 Subject: [PATCH 2/2] fix: correct proxy for host --- configs/nginx-dev.conf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/configs/nginx-dev.conf b/configs/nginx-dev.conf index 22810f4..e5bfd2d 100644 --- a/configs/nginx-dev.conf +++ b/configs/nginx-dev.conf @@ -27,6 +27,8 @@ http { resolver 127.0.0.11 valid=30s; # Docker DNS proxy_pass http://host.docker.internal:3001/api/; # Local back end proxy_redirect default; + + proxy_set_header Host $host; } #OIDC Provider @@ -34,6 +36,9 @@ http { resolver 127.0.0.11 valid=30s; # Docker DNS proxy_pass http://host.docker.internal:3001/oidc/; # Local back end proxy_redirect default; + + #Needed for Host File + proxy_set_header Host $host; } #Frontend Next.js App @@ -41,6 +46,9 @@ http { resolver 127.0.0.11 valid=30s; # Docker DNS proxy_pass http://host.docker.internal:3000/; # Local back end proxy_redirect default; + # Change the host header to the original host + + proxy_set_header Host $host; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade;