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.
This commit is contained in:
parent
ca8fdbc79b
commit
40902f001a
@ -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");
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user