fix: redid email verification endpoint
fix: corrected api prefix
This commit is contained in:
parent
9689a328b9
commit
42dd32eed4
2 changed files with 9 additions and 34 deletions
|
@ -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<any> {
|
||||
public async verifyEmail(@Query('code') code: string): Promise<any> {
|
||||
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' };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in a new issue