mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-12-08 20:29:05 +00:00
allow emails without a tld (#2762)
It's perfectly valid to have an email address without a TLD, for instance: - test@localhost - test@svc-in-same-k8s-namespace - test@internal-corp Fixes #2667
This commit is contained in:
@@ -3,6 +3,15 @@ import { validateSync } from 'class-validator';
|
||||
import { LoginCredentialDto } from './login-credential.dto';
|
||||
|
||||
describe('LoginCredentialDto', () => {
|
||||
it('should allow emails without a tld', () => {
|
||||
const someEmail = 'test@test';
|
||||
|
||||
const dto = plainToInstance(LoginCredentialDto, { email: someEmail, password: 'password' });
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(0);
|
||||
expect(dto.email).toEqual(someEmail);
|
||||
});
|
||||
|
||||
it('should fail without an email', () => {
|
||||
const dto = plainToInstance(LoginCredentialDto, { password: 'password' });
|
||||
const errors = validateSync(dto);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Transform } from 'class-transformer';
|
||||
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class LoginCredentialDto {
|
||||
@IsEmail()
|
||||
@IsEmail({ require_tld: false })
|
||||
@ApiProperty({ example: 'testuser@email.com' })
|
||||
@Transform(({ value }) => value.toLowerCase())
|
||||
email!: string;
|
||||
|
||||
@@ -30,6 +30,20 @@ describe('SignUpDto', () => {
|
||||
expect(errors[0].property).toEqual('email');
|
||||
});
|
||||
|
||||
it('should allow emails without a tld', () => {
|
||||
const someEmail = 'test@test';
|
||||
|
||||
const dto = plainToInstance(SignUpDto, {
|
||||
email: someEmail,
|
||||
password: 'password',
|
||||
firstName: 'first name',
|
||||
lastName: 'last name',
|
||||
});
|
||||
const errors = validateSync(dto);
|
||||
expect(errors).toHaveLength(0);
|
||||
expect(dto.email).toEqual(someEmail);
|
||||
});
|
||||
|
||||
it('should make the email all lowercase', () => {
|
||||
const dto = plainToInstance(SignUpDto, {
|
||||
email: 'TeSt@ImMiCh.com',
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Transform } from 'class-transformer';
|
||||
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class SignUpDto {
|
||||
@IsEmail()
|
||||
@IsEmail({ require_tld: false })
|
||||
@ApiProperty({ example: 'testuser@email.com' })
|
||||
@Transform(({ value }) => value.toLowerCase())
|
||||
email!: string;
|
||||
|
||||
Reference in New Issue
Block a user