1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

Fixed different lettercases in email create different user (#470)

* Fixed different lettercases in email create different user

* Fixed test
This commit is contained in:
Alex 2022-08-15 19:11:08 -05:00 committed by GitHub
parent c1b22125fd
commit 86f780871c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 5 deletions

View File

@ -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<LoginResponseDto> {
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<AdminSignupResponseDto> {
async adminSignUp(
@Body(new ValidationPipe({ transform: true })) signUpCredential: SignUpDto,
): Promise<AdminSignupResponseDto> {
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;
}
}

View File

@ -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()

View File

@ -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()

View File

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

View File

@ -61,7 +61,9 @@ export class UserController {
@ApiBearerAuth()
@UseGuards(AdminRolesGuard)
@Post()
async createUser(@Body(ValidationPipe) createUserDto: CreateUserDto): Promise<UserResponseDto> {
async createUser(
@Body(new ValidationPipe({ transform: true })) createUserDto: CreateUserDto,
): Promise<UserResponseDto> {
return await this.userService.createUser(createUserDto);
}