diff --git a/react-email-preview/emails/EmailAddressVerificationOtp.stories.tsx b/react-email-preview/emails/EmailAddressVerificationOtp.stories.tsx index 6c4a698483..0704b8d3c3 100644 --- a/react-email-preview/emails/EmailAddressVerificationOtp.stories.tsx +++ b/react-email-preview/emails/EmailAddressVerificationOtp.stories.tsx @@ -20,4 +20,5 @@ Default.args = { otp: '123456', minutesToExpiry: 30, appName: 'FormSG', + formUrl: 'https://form.gov.sg/645b5f5372deb40012fe98123', } diff --git a/src/app/modules/verification/verification.service.ts b/src/app/modules/verification/verification.service.ts index 078deebfda..45a5c13e4d 100644 --- a/src/app/modules/verification/verification.service.ts +++ b/src/app/modules/verification/verification.service.ts @@ -470,7 +470,7 @@ const sendOtpForField = ( : errAsync(new MalformedParametersError('Field id not present')) case BasicField.Email: // call email - it should validate the recipient - return MailService.sendVerificationOtp(recipient, otp, otpPrefix) + return MailService.sendVerificationOtp(recipient, otp, otpPrefix, formId) default: return errAsync(new NonVerifiedFieldTypeError(fieldType)) } diff --git a/src/app/services/mail/__tests__/mail.service.spec.ts b/src/app/services/mail/__tests__/mail.service.spec.ts index 052c83ae9a..aafcaab2e9 100644 --- a/src/app/services/mail/__tests__/mail.service.spec.ts +++ b/src/app/services/mail/__tests__/mail.service.spec.ts @@ -78,6 +78,8 @@ describe('mail.service', () => { describe('sendVerificationOtp', () => { const MOCK_OTP = '123456' + const MOCK_FORM_ID = 'mockFormId' + const MOCK_FORM_URL = `${MOCK_APP_URL}/${MOCK_FORM_ID}` const expectedArg = expect.objectContaining({ to: MOCK_VALID_EMAIL, @@ -96,6 +98,7 @@ describe('mail.service', () => { MOCK_VALID_EMAIL, MOCK_OTP, MOCK_OTP_PREFIX, + MOCK_FORM_URL, ) // Assert @@ -114,6 +117,7 @@ describe('mail.service', () => { invalidEmail, MOCK_OTP, MOCK_OTP_PREFIX, + MOCK_FORM_URL, ) // Assert @@ -138,6 +142,7 @@ describe('mail.service', () => { MOCK_VALID_EMAIL, MOCK_OTP, MOCK_OTP_PREFIX, + MOCK_FORM_URL, ) // Assert @@ -162,6 +167,7 @@ describe('mail.service', () => { MOCK_VALID_EMAIL, MOCK_OTP, MOCK_OTP_PREFIX, + MOCK_FORM_URL, ) // Assert @@ -192,6 +198,7 @@ describe('mail.service', () => { MOCK_VALID_EMAIL, MOCK_OTP, MOCK_OTP_PREFIX, + MOCK_FORM_URL, ) // Assert diff --git a/src/app/services/mail/mail.service.ts b/src/app/services/mail/mail.service.ts index f7d30c5b19..037c89ae33 100644 --- a/src/app/services/mail/mail.service.ts +++ b/src/app/services/mail/mail.service.ts @@ -338,15 +338,20 @@ export class MailService { recipient: string, otp: string, otpPrefix: string, + formId: string, ): ResultAsync => { const minutesToExpiry = Math.floor(HASH_EXPIRE_AFTER_SECONDS / 60) + const formUrl = this.#appUrl + `/${formId}` + const htmlData: EmailAddressVerificationOtpHtmlData = { appName: this.#appName, minutesToExpiry, otp, otpPrefix, + formUrl, } + const generatedHtml = fromPromise( render(EmailAddressVerificationOtp(htmlData)), (e) => { diff --git a/src/app/views/templates/EmailAddressVerificationOtp.tsx b/src/app/views/templates/EmailAddressVerificationOtp.tsx index 7bda8dab5c..ccc1814bb1 100644 --- a/src/app/views/templates/EmailAddressVerificationOtp.tsx +++ b/src/app/views/templates/EmailAddressVerificationOtp.tsx @@ -5,6 +5,7 @@ export type EmailAddressVerificationOtpHtmlData = { otp: string minutesToExpiry: number appName: string + formUrl: string } export const EmailAddressVerificationOtp = ({ @@ -12,15 +13,19 @@ export const EmailAddressVerificationOtp = ({ otp, minutesToExpiry, appName, + formUrl, }: EmailAddressVerificationOtpHtmlData): JSX.Element => { return ( - You are currently submitting a form on {appName}. + + You are trying to verify your email address on the following form:{' '} + {formUrl}. + Your OTP is {otpPrefix}-{otp}. It will expire in{' '} - {minutesToExpiry} minutes. Please use this to verify your submission. + {minutesToExpiry} minutes. Never share your OTP with anyone else. If you did not request this