From 421114a3dfd38f4c3d73edb3891d3ed6a39ef2bf Mon Sep 17 00:00:00 2001 From: Piyush Date: Tue, 17 Nov 2026 13:37:29 +0000 Subject: [PATCH] updating additional will go through validate email regex test --- src/service/PersonalInfo/EmailService.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/service/PersonalInfo/EmailService.js b/src/service/PersonalInfo/EmailService.js index 82eb8a0..5359670 100644 --- a/src/service/PersonalInfo/EmailService.js +++ b/src/service/PersonalInfo/EmailService.js @@ -4,8 +4,7 @@ import { generateOcsUrl } from '@nextcloud/router' import { confirmPassword } from '@nextcloud/password-confirmation' import '@nextcloud/password-confirmation/dist/style.css' import { convertEmailDomainToASCII } from '../../utils/email.js' - -import { ACCOUNT_PROPERTY_ENUM, SCOPE_SUFFIX } from '../../constants/AccountPropertyConstants.js' +import { ACCOUNT_PROPERTY_ENUM, SCOPE_SUFFIX, VALIDATE_EMAIL_REGEX } from '../../constants/AccountPropertyConstants.js' /** * Save the primary email of the user @@ -97,6 +96,10 @@ export const removeAdditionalEmail = async (email) => { * @return {object} */ export const updateAdditionalEmail = async (prevEmail, newEmail) => { + if (newEmail !== '' && !VALIDATE_EMAIL_REGEX.test(convertEmailDomainToASCII(newEmail))) { + throw new Error('Invalid email address') + } + const userId = getCurrentUser().uid const url = generateOcsUrl('cloud/users/{userId}/{collection}', { userId, collection: ACCOUNT_PROPERTY_ENUM.EMAIL_COLLECTION })