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; }