diff --git a/client/src/app/infrastructure/utils/validators/email.ts b/client/src/app/infrastructure/utils/validators/email.ts new file mode 100644 index 0000000000..c03326e852 --- /dev/null +++ b/client/src/app/infrastructure/utils/validators/email.ts @@ -0,0 +1,20 @@ +import {AbstractControl, ValidationErrors, ValidatorFn} from '@angular/forms'; + +const EMAIL_VALIDATION_REGEX = /[A-Z0-9._+\-ÄÖÜ]+@[A-Z0-9.\-ÄÖÜ]+\.[A-ZÄÖÜ]{2,}/i + +export function createEmailValidator(): ValidatorFn { + return (control:AbstractControl) : ValidationErrors | null => { + + const value = control.value; + + if (!value) { + return null; + } + + const validEmail = EMAIL_VALIDATION_REGEX.test(value); + if (!validEmail) { + return {"email": "Please enter a valid email address"}; + } + return null; + } +} diff --git a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts index 726a87f6d1..2f29fccdc4 100644 --- a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts +++ b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts @@ -18,6 +18,7 @@ import { BaseUiComponent } from 'src/app/ui/base/base-ui-component'; import { GENDERS } from '../../../../../domain/models/users/user'; import { ViewUser } from '../../../../../site/pages/meetings/view-models/view-user'; import { OneOfValidator } from '../../validators'; +import { createEmailValidator } from 'src/app/infrastructure/utils/validators/email'; @Component({ selector: `os-user-detail-view`, @@ -294,7 +295,7 @@ export class UserDetailViewComponent extends BaseUiComponent implements OnInit, first_name: [``], last_name: [``], gender: [``], - email: [``, [Validators.email]], + email: [``, [createEmailValidator()]], last_email_sent: [``], default_password: [``], is_active: [true], diff --git a/client/src/app/site/pages/login/pages/reset-password/components/reset-password/reset-password.component.ts b/client/src/app/site/pages/login/pages/reset-password/components/reset-password/reset-password.component.ts index 1bec55a54a..b07a894134 100644 --- a/client/src/app/site/pages/login/pages/reset-password/components/reset-password/reset-password.component.ts +++ b/client/src/app/site/pages/login/pages/reset-password/components/reset-password/reset-password.component.ts @@ -4,6 +4,7 @@ import { TranslateService } from '@ngx-translate/core'; import { BaseComponent } from 'src/app/site/base/base.component'; import { ComponentServiceCollectorService } from 'src/app/site/services/component-service-collector.service'; import { UserControllerService } from 'src/app/site/services/user-controller.service'; +import { createEmailValidator } from 'src/app/infrastructure/utils/validators/email'; @Component({ selector: `os-reset-password`, @@ -33,7 +34,7 @@ export class ResetPasswordComponent extends BaseComponent implements OnInit { ) { super(componentServiceCollector, translate); this.resetPasswordForm = formBuilder.group({ - email: [``, [Validators.required, Validators.email]] + email: [``, [Validators.required, createEmailValidator()]] }); } diff --git a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.ts b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.ts index 767c23c016..8cf63309b5 100644 --- a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.ts +++ b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.ts @@ -15,6 +15,7 @@ import { MeetingComponentServiceCollectorService } from 'src/app/site/pages/meet import { PERSONAL_FORM_CONTROLS, ViewUser } from 'src/app/site/pages/meetings/view-models/view-user'; import { OrganizationSettingsService } from 'src/app/site/pages/organization/services/organization-settings.service'; import { UserService } from 'src/app/site/services/user.service'; +import { createEmailValidator } from 'src/app/infrastructure/utils/validators/email'; import { GroupControllerService } from '../../../../../../modules/groups/services/group-controller.service'; import { @@ -152,7 +153,7 @@ export class ParticipantCreateWizardComponent extends BaseMeetingComponent imple username: [``], first_name: [``], last_name: [``], - email: [``, Validators.email] + email: [``, createEmailValidator()] }, { validators: [OneOfValidator.validation([`username`, `first_name`, `last_name`, `email`], `name`)] diff --git a/client/src/app/site/pages/meetings/services/meeting-settings-definition.service/meeting-settings-definitions.ts b/client/src/app/site/pages/meetings/services/meeting-settings-definition.service/meeting-settings-definitions.ts index 9cdfb48f96..d459a9fdb3 100644 --- a/client/src/app/site/pages/meetings/services/meeting-settings-definition.service/meeting-settings-definitions.ts +++ b/client/src/app/site/pages/meetings/services/meeting-settings-definition.service/meeting-settings-definitions.ts @@ -9,6 +9,7 @@ import { PollTypeVerbose } from 'src/app/domain/models/poll/poll-constants'; import { ObjectReplaceKeysConfig } from 'src/app/infrastructure/utils'; +import { createEmailValidator } from 'src/app/infrastructure/utils/validators/email'; import { OrganizationSettingsService } from '../../../organization/services/organization-settings.service'; import { AssignmentPollMethodVerbose } from '../../pages/assignments/modules/assignment-poll/definitions'; @@ -905,7 +906,7 @@ export const meetingSettings: SettingsGroup[] = fillInSettingsDefaults([ key: `users_email_replyto`, label: _(`Reply address`), type: `email`, - validators: [Validators.email] + validators: [createEmailValidator()] }, { key: `users_email_subject`, diff --git a/client/src/app/site/pages/organization/pages/settings/modules/settings-detail/components/organization-settings/organization-settings.component.ts b/client/src/app/site/pages/organization/pages/settings/modules/settings-detail/components/organization-settings/organization-settings.component.ts index 955bd129b0..e1fc8a9359 100644 --- a/client/src/app/site/pages/organization/pages/settings/modules/settings-detail/components/organization-settings/organization-settings.component.ts +++ b/client/src/app/site/pages/organization/pages/settings/modules/settings-detail/components/organization-settings/organization-settings.component.ts @@ -10,6 +10,7 @@ import { OrganizationControllerService } from 'src/app/site/pages/organization/s import { ViewOrganization } from 'src/app/site/pages/organization/view-models/view-organization'; import { ComponentServiceCollectorService } from 'src/app/site/services/component-service-collector.service'; import { OperatorService } from 'src/app/site/services/operator.service'; +import { createEmailValidator } from 'src/app/infrastructure/utils/validators/email'; @Component({ selector: `os-organization-settings`, @@ -70,7 +71,7 @@ export class OrganizationSettingsComponent extends BaseComponent { privacy_policy: [this._currentOrgaSettings.privacy_policy], login_text: [this._currentOrgaSettings.login_text], users_email_body: [this._currentOrgaSettings.users_email_body], - users_email_replyto: [this._currentOrgaSettings.users_email_replyto, [Validators.email]], + users_email_replyto: [this._currentOrgaSettings.users_email_replyto, [createEmailValidator()]], users_email_sender: [this._currentOrgaSettings.users_email_sender], users_email_subject: [this._currentOrgaSettings.users_email_subject], default_language: [this._currentOrgaSettings.default_language]