Compare commits
2 commits
main
...
public-fol
Author | SHA1 | Date | |
---|---|---|---|
|
1ee6db7bec | ||
|
4a275b166e |
9 changed files with 43 additions and 25 deletions
|
@ -1,10 +1,12 @@
|
|||
import { Body, Controller, Get, Post, Query, Req, Res } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Body, Controller, Get, Post, Query, Render, Req, Res, UseGuards } from '@nestjs/common';
|
||||
import { ApiExcludeEndpoint, ApiResponse, 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';
|
||||
|
||||
|
@ -46,18 +48,34 @@ export class AuthController {
|
|||
return await this.authService.sendVerificationEmail(body.email);
|
||||
}
|
||||
|
||||
// ==== Render pages ==== //
|
||||
|
||||
@Get('verify-email')
|
||||
public async verifyEmail(@Query('code') code: string): Promise<any> {
|
||||
@UseGuards(ViewLoginGuard)
|
||||
@ApiExcludeEndpoint()
|
||||
public async verifyEmail(@Res() response: Response, @Query('code') code: string): Promise<any> {
|
||||
if (!code) {
|
||||
return { error: true, message: 'Invalid Verification 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',
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await this.authService.markEmailVerified(code);
|
||||
|
||||
return { error: false, message: 'Email Verified' };
|
||||
} catch (e) {
|
||||
return { error: true, message: 'Invalid Verification 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',
|
||||
});
|
||||
}
|
||||
|
||||
response.redirect('/auth/login');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,14 @@ async function bootstrap() {
|
|||
app.disable('x-powered-by');
|
||||
|
||||
app.setGlobalPrefix('api', {
|
||||
exclude: [{ path: 'oidc/:splat*', method: RequestMethod.ALL }],
|
||||
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 },
|
||||
],
|
||||
});
|
||||
|
||||
app.enableVersioning({
|
||||
|
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
@ -3,12 +3,12 @@ import localFont from "next/font/local";
|
|||
import "./globals.css";
|
||||
|
||||
const geistSans = localFont({
|
||||
src: "./fonts/GeistVF.woff",
|
||||
src: "../../public/fonts/GeistVF.woff",
|
||||
variable: "--font-geist-sans",
|
||||
weight: "100 900",
|
||||
});
|
||||
const geistMono = localFont({
|
||||
src: "./fonts/GeistMonoVF.woff",
|
||||
src: "../../public/fonts/GeistMonoVF.woff",
|
||||
variable: "--font-geist-mono",
|
||||
weight: "100 900",
|
||||
});
|
||||
|
|
|
@ -23,7 +23,10 @@
|
|||
{
|
||||
"name": "next"
|
||||
}
|
||||
]
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./app/*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
|
|
|
@ -20,7 +20,10 @@
|
|||
{
|
||||
"name": "next"
|
||||
}
|
||||
]
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./app/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
|
|
|
@ -27,8 +27,6 @@ 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
|
||||
|
@ -36,9 +34,6 @@ 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
|
||||
|
@ -46,14 +41,6 @@ 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;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue