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..d7d51c6fcf --- /dev/null +++ b/client/src/app/infrastructure/utils/validators/email.ts @@ -0,0 +1,19 @@ +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 05fd194eae..631769d776 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 @@ -12,6 +12,7 @@ import { } from '@angular/core'; import { UntypedFormBuilder, UntypedFormGroup, ValidatorFn, Validators } from '@angular/forms'; import { Subscription } from 'rxjs'; +import { createEmailValidator } from 'src/app/infrastructure/utils/validators/email'; import { OperatorService } from 'src/app/site/services/operator.service'; import { BaseUiComponent } from 'src/app/ui/base/base-ui-component'; @@ -294,7 +295,7 @@ export class UserDetailViewComponent extends BaseUiComponent implements OnInit, first_name: [``], last_name: [``], gender: [``], - 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..6fee15dfde 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 @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; import { TranslateService } from '@ngx-translate/core'; +import { createEmailValidator } from 'src/app/infrastructure/utils/validators/email'; 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'; @@ -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 7be55d1911..04b7418b87 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 @@ -7,6 +7,7 @@ import { BehaviorSubject, distinctUntilChanged, Observable } from 'rxjs'; import { Id } from 'src/app/domain/definitions/key-types'; import { User } from 'src/app/domain/models/users/user'; import { SearchUsersPresenterService } from 'src/app/gateways/presenter/search-users-presenter.service'; +import { createEmailValidator } from 'src/app/infrastructure/utils/validators/email'; import { OneOfValidator, UserDetailViewComponent } from 'src/app/site/modules/user-components'; import { BaseMeetingComponent } from 'src/app/site/pages/meetings/base/base-meeting.component'; import { ViewGroup } from 'src/app/site/pages/meetings/pages/participants'; @@ -152,7 +153,7 @@ export class ParticipantCreateWizardComponent extends BaseMeetingComponent imple username: [``], first_name: [``], last_name: [``], - 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/accounts/pages/account-detail/components/account-detail/account-detail.component.html b/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail/account-detail.component.html index a74dfacd19..a5bd7d4987 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail/account-detail.component.html +++ b/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail/account-detail.component.html @@ -75,6 +75,9 @@