mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00: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:
parent
c1b22125fd
commit
86f780871c
5 changed files with 14 additions and 5 deletions
|
@ -25,7 +25,7 @@ export class AuthController {
|
||||||
|
|
||||||
@Post('/login')
|
@Post('/login')
|
||||||
async login(
|
async login(
|
||||||
@Body(ValidationPipe) loginCredential: LoginCredentialDto,
|
@Body(new ValidationPipe({ transform: true })) loginCredential: LoginCredentialDto,
|
||||||
@Res() response: Response,
|
@Res() response: Response,
|
||||||
): Promise<LoginResponseDto> {
|
): Promise<LoginResponseDto> {
|
||||||
const loginResponse = await this.authService.login(loginCredential);
|
const loginResponse = await this.authService.login(loginCredential);
|
||||||
|
@ -42,7 +42,9 @@ export class AuthController {
|
||||||
|
|
||||||
@Post('/admin-sign-up')
|
@Post('/admin-sign-up')
|
||||||
@ApiBadRequestResponse({ description: 'The server already has an admin' })
|
@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);
|
return await this.authService.adminSignUp(signUpCredential);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +63,7 @@ export class AuthController {
|
||||||
|
|
||||||
const status = new LogoutResponseDto(true);
|
const status = new LogoutResponseDto(true);
|
||||||
|
|
||||||
response.send(status)
|
response.send(status);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Transform } from 'class-transformer';
|
||||||
import { IsNotEmpty } from 'class-validator';
|
import { IsNotEmpty } from 'class-validator';
|
||||||
|
|
||||||
export class LoginCredentialDto {
|
export class LoginCredentialDto {
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@ApiProperty({ example: 'testuser@email.com' })
|
@ApiProperty({ example: 'testuser@email.com' })
|
||||||
|
@Transform(({ value }) => value?.toLowerCase())
|
||||||
email!: string;
|
email!: string;
|
||||||
|
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Transform } from 'class-transformer';
|
||||||
import { IsNotEmpty, IsEmail } from 'class-validator';
|
import { IsNotEmpty, IsEmail } from 'class-validator';
|
||||||
|
|
||||||
export class SignUpDto {
|
export class SignUpDto {
|
||||||
@IsEmail()
|
@IsEmail()
|
||||||
@ApiProperty({ example: 'testuser@email.com' })
|
@ApiProperty({ example: 'testuser@email.com' })
|
||||||
|
@Transform(({ value }) => value?.toLowerCase())
|
||||||
email!: string;
|
email!: string;
|
||||||
|
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Transform } from 'class-transformer';
|
||||||
import { IsNotEmpty, IsEmail } from 'class-validator';
|
import { IsNotEmpty, IsEmail } from 'class-validator';
|
||||||
|
|
||||||
export class CreateUserDto {
|
export class CreateUserDto {
|
||||||
@IsEmail()
|
@IsEmail()
|
||||||
|
@Transform(({ value }) => value?.toLowerCase())
|
||||||
@ApiProperty({ example: 'testuser@email.com' })
|
@ApiProperty({ example: 'testuser@email.com' })
|
||||||
email!: string;
|
email!: string;
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,9 @@ export class UserController {
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@UseGuards(AdminRolesGuard)
|
@UseGuards(AdminRolesGuard)
|
||||||
@Post()
|
@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);
|
return await this.userService.createUser(createUserDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue