Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@hapi/boom": "^9.1.1",
"@hapi/hapi": "^20.0.1",
"@hapi/inert": "^6.0.3",
"@opencrvs/toolkit": "1.8.1-rc.591e5a8",
"@opencrvs/toolkit": "1.8.1-rc.c8c6227",
"@types/chalk": "^2.2.0",
"@types/csv2json": "^1.4.0",
"@types/fhir": "^0.0.30",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,132 @@ exports[`User notification - Email > 2fa 1`] = `
}
`;

exports[`User notification - Email > change-email-address 1`] = `
{
"from": "",
"html": "<!DOCTYPE html>
<html>

<head>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap" rel="stylesheet" />
<style type="text/css">
body {
font-family: 'Noto Sans', sans-serif;
color: #222;
padding: 16px 24px;
}

h1 {
font-size: 21px;
margin-top: 32px;
margin-bottom: 36px;
font-weight: 700;
}

p {
font-weight: 400;
font-size: 16px;
line-height: 1.8;
margin-bottom: 24px;
}

i {
color: #666;
font-weight: 400;
font-size: 16px;
}
</style>
</head>

<body>
<img src="http://localhost:3040/content/country-logo" alt="country_logo" style="max-height: 88px;
max-width: 100%;">
<h1>Change email address</h1>
<p>
Hello John,
</p>
<p>
You recently requested to change your email address for your Farajaland CRS account.
</p>
<p>
To confirm this change, use the code: <strong>654321</strong>
</p>
</br>
<p>
Best regards, <br />
Farajaland CRS Team
</p>
</body>

</html>",
"subject": "Email address change request",
"to": "[email protected]",
}
`;

exports[`User notification - Email > change-phone-number 1`] = `
{
"from": "",
"html": "<!DOCTYPE html>
<html>

<head>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap" rel="stylesheet" />
<style type="text/css">
body {
font-family: 'Noto Sans', sans-serif;
color: #222;
padding: 16px 24px;
}

h1 {
font-size: 21px;
margin-top: 32px;
margin-bottom: 36px;
font-weight: 700;
}

p {
font-weight: 400;
font-size: 16px;
line-height: 1.8;
margin-bottom: 24px;
}

i {
color: #666;
font-weight: 400;
font-size: 16px;
}
</style>
</head>

<body>
<img src="http://localhost:3040/content/country-logo" alt="country_logo" style="max-height: 88px;
max-width: 100%;">
<h1>Change phone number</h1>
<p>
Hello John,
</p>
<p>
You recently requested to change your phone number for your Farajaland CRS account.
</p>
<p>
To confirm this change, use the code: <strong>123456</strong>
</p>
</br>
<p>
Best regards, <br />
Farajaland CRS Team
</p>
</body>

</html>",
"subject": "Phone number change request",
"to": "[email protected]",
}
`;

exports[`User notification - Email > reset-password 1`] = `
{
"from": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

exports[`User notification - sms > 2fa 1`] = `"{"messages":[{"destinations":[{"recipient":"+15551234567"}],"from":"mock_sender","text":"Your OpenCRVS authentication code is: 102030"}]}"`;

exports[`User notification - sms > change-email-address 1`] = `"{"messages":[{"destinations":[{"recipient":"+15551234567"}],"from":"mock_sender","text":"Your OpenCRVS authentication code is: 654321"}]}"`;

exports[`User notification - sms > change-phone-number 1`] = `"{"messages":[{"destinations":[{"recipient":"+15551234567"}],"from":"mock_sender","text":"Your OpenCRVS authentication code is: 123456"}]}"`;

exports[`User notification - sms > reset-password 1`] = `"{"messages":[{"destinations":[{"recipient":"+15551234567"}],"from":"mock_sender","text":"Use the code 112233 to reset your Farajaland CRS password. This code expires in 10 minutes."}]}"`;

exports[`User notification - sms > reset-password-by-admin 1`] = `"{"messages":[{"destinations":[{"recipient":"+15551234567"}],"from":"mock_sender","text":"Your password has been reset. Please login to Farajaland CRS with the temporary password: tempPass123."}]}"`;
Expand Down
8 changes: 8 additions & 0 deletions src/api/notification/email-templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ export const TriggerVariable = {
[TriggerEvent.ALL_USER_NOTIFICATION]: z.object({
subject: z.string(),
body: z.string()
}),
[TriggerEvent.CHANGE_EMAIL_ADDRESS]: z.object({
firstname: z.string(),
code: z.string()
}),
[TriggerEvent.CHANGE_PHONE_NUMBER]: z.object({
firstname: z.string(),
code: z.string()
})
} as const

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
max-width: 100%;">
<h1>Change email address</h1>
<p>
Hello {{firstNames}},
Hello {{firstname}},
</p>
<p>
You recently requested to change your email address for your {{applicationName}} account.
</p>
<p>
To confirm this change, use the code: <strong>{{authCode}}</strong>
To confirm this change, use the code: <strong>{{code}}</strong>
</p>
</br>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
max-width: 100%;">
<h1>Change phone number</h1>
<p>
Hello {{firstNames}},
Hello {{firstname}},
</p>
<p>
You recently requested to change your phone number for your {{applicationName}} account.
</p>
<p>
To confirm this change, use the code: <strong>{{authCode}}</strong>
To confirm this change, use the code: <strong>{{code}}</strong>
</p>
</br>
<p>
Expand Down
2 changes: 2 additions & 0 deletions src/api/notification/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ function convertPayloadToVariable({
}

case TriggerEvent.TWO_FA:
case TriggerEvent.CHANGE_EMAIL_ADDRESS:
case TriggerEvent.CHANGE_PHONE_NUMBER:
return {
firstname,
code: payload.code
Expand Down
4 changes: 3 additions & 1 deletion src/api/notification/sms-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ export const TriggerToSMSTemplate = {
['reset-password']: 'resetUserPasswordNotification',
['reset-password-by-admin']: 'resetUserPasswordByAdminNotification',
['2fa']: 'authenticationCodeNotification',
['all-user-notification']: 'allUserNotification'
['all-user-notification']: 'allUserNotification',
['change-email-address']: 'authenticationCodeNotification',
['change-phone-number']: 'authenticationCodeNotification'
} satisfies Record<TriggerEvent, SMSTemplateType>

function isTriggerEvent(event: any): event is TriggerEvent {
Expand Down
16 changes: 15 additions & 1 deletion src/api/notification/testData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Recipient } from '@opencrvs/toolkit/notification'
import { Recipient, TriggerEvent } from '@opencrvs/toolkit/notification'
import { UUID } from '@opencrvs/toolkit/events'
import { TriggerEventPayloadPair } from './handler'
import {
Expand Down Expand Up @@ -71,6 +71,20 @@ export const userNotificationTestData: TriggerEventPayloadPair[] = [
role: 'NATIONAL_SYSTEM_ADMIN'
}
}
},
{
event: TriggerEvent.CHANGE_EMAIL_ADDRESS,
payload: {
recipient,
code: '654321'
}
},
{
event: TriggerEvent.CHANGE_PHONE_NUMBER,
payload: {
recipient,
code: '123456'
}
}
]

Expand Down
20 changes: 20 additions & 0 deletions src/config/routes/userNotificationRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ export default function getUserNotificationRoutes(): ServerRoute<ReqRefDefaults>
tags: ['api'],
description: 'Handles broadcast for all user '
}
},
{
method: 'POST',
path: '/triggers/user/change-phone-number',
handler: makeNotificationHandler('change-phone-number'),
options: {
auth: false,
tags: ['api'],
description: 'Handles verification for phone number change'
}
},
{
method: 'POST',
path: '/triggers/user/change-email-address',
handler: makeNotificationHandler('change-email-address'),
options: {
auth: false,
tags: ['api'],
description: 'Handles verification for email address change'
}
}
]
}
2 changes: 1 addition & 1 deletion src/translations/client.csv
Original file line number Diff line number Diff line change
Expand Up @@ -797,13 +797,13 @@ event.action.notAvailableForEvent,Shown when user tries to perform an action tha
event.action.outbox-retry.label,Label for retry button for outbox,Retry,Réessayer
event.action.review-correction.label,Label for review correction button in dropdown menu,Review,Revoir
event.birth.action.archive.label,Label for archive record button in dropdown menu,Archive,Aarchiver
event.birth.action.certificate.form.section.verifyIdentity.data.label,Label for identity verification data block,"Identity details","Détails de l'identité"
event.birth.action.certificate.form.section.collectPayment.data.label,Title for the data section,Payment details,Détails du paiement
event.birth.action.certificate.form.section.collectPayment.fee.label,Title for the data entry,Fee,Frais
event.birth.action.certificate.form.section.collectPayment.service.label,Title for the data entry,Service,Service
event.birth.action.certificate.form.section.collectPayment.service.label.afterLateRegistrationTarget,Birth registration after 365 days of date of birth,Birth registration after 365 days of date of birth,Enregistrement de naissance après 365 jours de la date de naissance
event.birth.action.certificate.form.section.collectPayment.service.label.beforeRegistrationTarget,Birth registration before 30 days of date of birth,Birth registration before 30 days of date of birth,Enregistrement de naissance avant 30 jours de la date de naissance
event.birth.action.certificate.form.section.collectPayment.service.label.inBetweenRegistrationTargets,Birth registration after 30 days but before 365 days of date of birth,Birth registration after 30 days but before 365 days of date of birth,Enregistrement de naissance après 30 jours mais avant 365 jours de la date de naissance
event.birth.action.certificate.form.section.verifyIdentity.data.label,Label for identity verification data block,Identity details,Détails de l'identité
event.birth.action.collect-certificate.label,This is shown as the action name anywhere the user can trigger the action from,Print,Imprimer
event.birth.action.correction.form.section.requester.identity.verify.title,This is the title of the section,Verify their identity,Vérifier l'identité
event.birth.action.declare.form.label,This is what this form is referred as in the system,Birth decalration form,Birth decalration form
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -834,10 +834,10 @@
dependencies:
"@octokit/openapi-types" "^18.0.0"

"@opencrvs/[email protected].591e5a8":
version "1.8.1-rc.591e5a8"
resolved "https://registry.yarnpkg.com/@opencrvs/toolkit/-/toolkit-1.8.1-rc.591e5a8.tgz#3c4c1507d047107c18bf215fedf07ed47dfeceeb"
integrity sha512-4QfnfKghyskYmhvkeBkBb6pYkD6bK223RZEmp2PS8qBBP7bV6hcCcgimeY61FLTmHurf5bRZr8rwbk9AQ5je5Q==
"@opencrvs/[email protected].c8c6227":
version "1.8.1-rc.c8c6227"
resolved "https://registry.yarnpkg.com/@opencrvs/toolkit/-/toolkit-1.8.1-rc.c8c6227.tgz#bac5a80475c4578e6aa802ae70aa4491872c6008"
integrity sha512-RdTYBVgJRc2aSrKuLbDRYpAXu1TOssTra6cTuPwoJV23X48NOWuyrSImHf0PUKyS2puF/6v73G1QYyE5FK38Kg==
dependencies:
"@trpc/client" "11.4.3"
"@trpc/server" "11.4.3"
Expand Down
Loading