diff --git a/server/apps/immich/src/api-v1/auth/auth.controller.ts b/server/apps/immich/src/api-v1/auth/auth.controller.ts index ea7d68f3ea..031c39610d 100644 --- a/server/apps/immich/src/api-v1/auth/auth.controller.ts +++ b/server/apps/immich/src/api-v1/auth/auth.controller.ts @@ -25,7 +25,7 @@ export class AuthController { @Post('/login') async login( - @Body(ValidationPipe) loginCredential: LoginCredentialDto, + @Body(new ValidationPipe({ transform: true })) loginCredential: LoginCredentialDto, @Res() response: Response, ): Promise { const loginResponse = await this.authService.login(loginCredential); @@ -42,7 +42,9 @@ export class AuthController { @Post('/admin-sign-up') @ApiBadRequestResponse({ description: 'The server already has an admin' }) - async adminSignUp(@Body(ValidationPipe) signUpCredential: SignUpDto): Promise { + async adminSignUp( + @Body(new ValidationPipe({ transform: true })) signUpCredential: SignUpDto, + ): Promise { return await this.authService.adminSignUp(signUpCredential); } @@ -61,8 +63,7 @@ export class AuthController { const status = new LogoutResponseDto(true); - response.send(status) + response.send(status); return status; } - } diff --git a/server/apps/immich/src/api-v1/auth/dto/login-credential.dto.ts b/server/apps/immich/src/api-v1/auth/dto/login-credential.dto.ts index 29ba5cf026..7426303528 100644 --- a/server/apps/immich/src/api-v1/auth/dto/login-credential.dto.ts +++ b/server/apps/immich/src/api-v1/auth/dto/login-credential.dto.ts @@ -1,9 +1,11 @@ import { ApiProperty } from '@nestjs/swagger'; +import { Transform } from 'class-transformer'; import { IsNotEmpty } from 'class-validator'; export class LoginCredentialDto { @IsNotEmpty() @ApiProperty({ example: 'testuser@email.com' }) + @Transform(({ value }) => value?.toLowerCase()) email!: string; @IsNotEmpty() diff --git a/server/apps/immich/src/api-v1/auth/dto/sign-up.dto.ts b/server/apps/immich/src/api-v1/auth/dto/sign-up.dto.ts index d8dbd8a8df..3358ddac31 100644 --- a/server/apps/immich/src/api-v1/auth/dto/sign-up.dto.ts +++ b/server/apps/immich/src/api-v1/auth/dto/sign-up.dto.ts @@ -1,9 +1,11 @@ import { ApiProperty } from '@nestjs/swagger'; +import { Transform } from 'class-transformer'; import { IsNotEmpty, IsEmail } from 'class-validator'; export class SignUpDto { @IsEmail() @ApiProperty({ example: 'testuser@email.com' }) + @Transform(({ value }) => value?.toLowerCase()) email!: string; @IsNotEmpty() diff --git a/server/apps/immich/src/api-v1/user/dto/create-user.dto.ts b/server/apps/immich/src/api-v1/user/dto/create-user.dto.ts index 13facfad34..d18f0a3237 100644 --- a/server/apps/immich/src/api-v1/user/dto/create-user.dto.ts +++ b/server/apps/immich/src/api-v1/user/dto/create-user.dto.ts @@ -1,8 +1,10 @@ import { ApiProperty } from '@nestjs/swagger'; +import { Transform } from 'class-transformer'; import { IsNotEmpty, IsEmail } from 'class-validator'; export class CreateUserDto { @IsEmail() + @Transform(({ value }) => value?.toLowerCase()) @ApiProperty({ example: 'testuser@email.com' }) email!: string; diff --git a/server/apps/immich/src/api-v1/user/user.controller.ts b/server/apps/immich/src/api-v1/user/user.controller.ts index 9e433c0076..e2eff4418c 100644 --- a/server/apps/immich/src/api-v1/user/user.controller.ts +++ b/server/apps/immich/src/api-v1/user/user.controller.ts @@ -61,7 +61,9 @@ export class UserController { @ApiBearerAuth() @UseGuards(AdminRolesGuard) @Post() - async createUser(@Body(ValidationPipe) createUserDto: CreateUserDto): Promise { + async createUser( + @Body(new ValidationPipe({ transform: true })) createUserDto: CreateUserDto, + ): Promise { return await this.userService.createUser(createUserDto); }