From 40902f001a87aa39751e4a9b3cc630da1216f620 Mon Sep 17 00:00:00 2001 From: MOHAN Date: Wed, 26 Aug 2026 18:11:20 +0530 Subject: [PATCH] Accept fullName on registration The register form collects a full name, but RegisterDto rejected it as an unknown field under the global whitelist validation pipe, so registration always failed 400 whenever a name was entered. --- src/auth/auth.service.ts | 3 ++- src/auth/dto/register.dto.ts | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 748ea60..4b37622 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -40,7 +40,8 @@ export class AuthService { if (existing) throw new BadRequestException("Email already registered."); const passwordHash = this.hashPassword(payload.password); - const user = await this.prisma.user.create({ data: { email, passwordHash } }); + const fullName = payload.fullName?.trim() || undefined; + const user = await this.prisma.user.create({ data: { email, passwordHash, fullName } }); await this.prisma.auditLog.create({ data: { userId: user.id, action: "auth.register", metadata: { email } } }); const verifyToken = crypto.randomBytes(32).toString("hex"); diff --git a/src/auth/dto/register.dto.ts b/src/auth/dto/register.dto.ts index 4c0163b..ad27fa2 100644 --- a/src/auth/dto/register.dto.ts +++ b/src/auth/dto/register.dto.ts @@ -1,4 +1,4 @@ -import { IsEmail, IsString, MinLength } from "class-validator"; +import { IsEmail, IsOptional, IsString, MaxLength, MinLength } from "class-validator"; export class RegisterDto { @IsEmail({}, { message: "Invalid email address." }) @@ -7,4 +7,9 @@ export class RegisterDto { @IsString() @MinLength(8, { message: "Password must be at least 8 characters." }) password!: string; + + @IsOptional() + @IsString() + @MaxLength(200) + fullName?: string; }