diff --git a/dictation_client/src/features/partner/selectors.ts b/dictation_client/src/features/partner/selectors.ts index e07fd82..061f8b1 100644 --- a/dictation_client/src/features/partner/selectors.ts +++ b/dictation_client/src/features/partner/selectors.ts @@ -8,8 +8,11 @@ export const selectInputValidationErrors = (state: RootState) => { const hasErrorEmptyAdminName = state.partner.apps.addPartner.adminName === ""; const hasErrorEmptyEmail = state.partner.apps.addPartner.email === ""; + const emailPattern = + /^[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]+@[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*\.[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*[a-zA-Z]$/; + const hasErrorIncorrectEmail = - (state.partner.apps.addPartner.email as string).match(/^[^@]+@[^@]+$/) + (state.partner.apps.addPartner.email as string).match(emailPattern) ?.length !== 1; return { diff --git a/dictation_client/src/features/signup/selectors.ts b/dictation_client/src/features/signup/selectors.ts index 823347f..29e3206 100644 --- a/dictation_client/src/features/signup/selectors.ts +++ b/dictation_client/src/features/signup/selectors.ts @@ -16,8 +16,10 @@ export const selectInputValidationErrors = (state: RootState) => { state.signup.apps.password ); + const emailPattern = + /^[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]+@[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*\.[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*[a-zA-Z]$/; const hasErrorIncorrectEmail = - (state.signup.apps.email as string).match(/^[^@]+@[^@]+$/)?.length !== 1; + (state.signup.apps.email as string).match(emailPattern)?.length !== 1; return { hasErrorEmptyEmail, diff --git a/dictation_client/src/features/user/selectors.ts b/dictation_client/src/features/user/selectors.ts index 0fd057d..e1e3cf1 100644 --- a/dictation_client/src/features/user/selectors.ts +++ b/dictation_client/src/features/user/selectors.ts @@ -26,7 +26,10 @@ export const selectInputValidationErrors = (state: RootState) => { role ); - const hasErrorIncorrectEmail = email.match(/^[^@]+@[^@]+$/)?.length !== 1; + const emailPattern = + /^[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]+@[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*\.[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*[a-zA-Z]$/; + + const hasErrorIncorrectEmail = email.match(emailPattern)?.length !== 1; const hasErrorIncorrectEncryptionPassword = checkErrorIncorrectEncryptionPassword(encryptionPassword, role, encryption); diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index 276fd0e..6e45d8e 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -38,7 +38,7 @@ export class CreateAccountRequest { @ApiProperty() adminName: string; @ApiProperty() - @IsEmail() + @IsEmail({ blacklisted_chars: '*' }) adminMail: string; @ApiProperty() @IsAdminPasswordvalid() @@ -244,7 +244,7 @@ export class CreatePartnerAccountRequest { @ApiProperty() adminName: string; @ApiProperty() - @IsEmail() + @IsEmail({ blacklisted_chars: '*' }) email: string; } diff --git a/dictation_server/src/features/users/types/types.ts b/dictation_server/src/features/users/types/types.ts index d21f72d..c6bcb75 100644 --- a/dictation_server/src/features/users/types/types.ts +++ b/dictation_server/src/features/users/types/types.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsIn } from 'class-validator'; +import { IsEmail, IsIn } from 'class-validator'; import { TASK_LIST_SORTABLE_ATTRIBUTES, USER_LICENSE_STATUS, @@ -88,6 +88,7 @@ export class SignupRequest { authorId?: string; @ApiProperty() + @IsEmail({ blacklisted_chars: '*' }) email: string; @ApiProperty()