From ac6549d4ef3dbddc2e9da773af629d07cc4a57fa Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 6 Dec 2024 13:47:09 -0500 Subject: [PATCH] [Fix] Updates `workEmailDomainRegex` (#12219) * Update workEmailDomainRegex * Update workEmailDomainRegex * Update workEmailDomainRegex --- api/app/GraphQL/Validators/UpdateUserAsUserInputValidator.php | 4 ++-- packages/helpers/src/constants/regularExpressions.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/app/GraphQL/Validators/UpdateUserAsUserInputValidator.php b/api/app/GraphQL/Validators/UpdateUserAsUserInputValidator.php index 42383ab0fc3..6091e3dcffc 100644 --- a/api/app/GraphQL/Validators/UpdateUserAsUserInputValidator.php +++ b/api/app/GraphQL/Validators/UpdateUserAsUserInputValidator.php @@ -45,8 +45,8 @@ public function rules(): array */ Rule::unique('users', 'email')->ignore($this->arg('id'), 'id'), Rule::unique('users', 'work_email')->ignore($this->arg('id'), 'id'), - // Note: Domains should be kept in sync with the workEmailDomainRegex - 'ends_with:gc.ca,canada.ca,elections.ca,ccc.ca,canadapost-postescanada.ca,gg.ca', + // Note: Should be kept in sync with the workEmailDomainRegex + 'regex:/@([A-Za-z0-9-]+\.)*(gc\.ca|canada\.ca|elections\.ca|ccc\.ca|canadapost-postescanada\.ca|gg\.ca)$/i', ], 'sub' => [ 'sometimes', diff --git a/packages/helpers/src/constants/regularExpressions.ts b/packages/helpers/src/constants/regularExpressions.ts index d1b1c36d60d..8f3619eb07a 100644 --- a/packages/helpers/src/constants/regularExpressions.ts +++ b/packages/helpers/src/constants/regularExpressions.ts @@ -8,7 +8,7 @@ export const keyStringRegex = /^[a-z]+[_a-z0-9]*$/; // See: https://regex101.com/r/EAZ8ha/6 export const phoneNumberRegex = /^\+[1-9]\d{1,14}$/; -// See: https://regex101.com/r/T8IYJU/3 +// See: https://regex101.com/r/T8IYJU/6 // Note: This should be kept in sync with the check in the UpdateUserInputValidator export const workEmailDomainRegex = - /(gc\.ca|canada\.ca|elections\.ca|ccc\.ca|canadapost-postescanada\.ca|gg\.ca)$/i; + /@([A-Za-z0-9-]+\.)*(gc\.ca|canada\.ca|elections\.ca|ccc\.ca|canadapost-postescanada\.ca|gg\.ca)$/i;