Skip to content

Commit 7995e29

Browse files
authored
Merge pull request #388 from SullyK/kls-config-v2
Updated KLS-Config-v2 and generalised paths for expired magic links
2 parents cd73f75 + d2a562c commit 7995e29

3 files changed

Lines changed: 56 additions & 54 deletions

File tree

runner/src/server/forms/kls-magic-link.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"name": "SentAnotherEmailButton",
102102
"options": {},
103103
"type": "Para",
104-
"content": "<a href='/magic-link/submit2' role='button' draggable='false' class='govuk-button' data-module='govuk-button' data-prevent-double-click='true'>Send a new email</button></a>",
104+
"content": "<a href='/kls-magic-link/submit2' role='button' draggable='false' class='govuk-button' data-module='govuk-button' data-prevent-double-click='true'>Send a new email</button></a>",
105105
"schema": {}
106106
}
107107
]
@@ -141,7 +141,7 @@
141141
"options": {},
142142
"type": "Para",
143143
"title": "If you've not received an email",
144-
"content": "<h3 class=\"govuk-heading-m\">If you've not received an email</h3><p class=\"govuk-body\">Check your spam or junk folder.<br><br>If you’ve still not received the email in 5 minutes, you need to request a new link.</p><a href='/magic-link' role='button' draggable='false' class='govuk-button' data-module='govuk-button' data-prevent-double-click='true'>Request a new link</button></a>",
144+
"content": "<h3 class=\"govuk-heading-m\">If you've not received an email</h3><p class=\"govuk-body\">Check your spam or junk folder.<br><br>If you’ve still not received the email in 5 minutes, you need to request a new link.</p><a href='/kls-magic-link' role='button' draggable='false' class='govuk-button' data-module='govuk-button' data-prevent-double-click='true'>Request a new link</button></a>",
145145
"schema": {}
146146
}
147147
],
@@ -180,7 +180,7 @@
180180
"name": "IncorrectEmail",
181181
"options": {},
182182
"type": "Para",
183-
"content": "The email you used does not match the email associated with this link.<br><br><a href='/magic-link' role='button' draggable='false' class='govuk-button' data-module='govuk-button' data-prevent-double-click='true'>Request a new link</button></a>",
183+
"content": "The email you used does not match the email associated with this link.<br><br><a href='/kls-magic-link' role='button' draggable='false' class='govuk-button' data-module='govuk-button' data-prevent-double-click='true'>Request a new link</button></a>",
184184
"schema": {}
185185
}
186186
]
@@ -192,7 +192,7 @@
192192
{
193193
"type": "Para",
194194
"title": "This link has expired",
195-
"content": "<a href='/magic-link' role='button' draggable='false' class='govuk-button' data-module='govuk-button' data-prevent-double-click='true'>Request a new link</button></a>",
195+
"content": "<a href='/kls-magic-link' role='button' draggable='false' class='govuk-button' data-module='govuk-button' data-prevent-double-click='true'>Request a new link</button></a>",
196196
"name": "blarGGH",
197197
"options": {},
198198
"schema": {}
@@ -204,7 +204,7 @@
204204
"confirmationPage": {
205205
"customText": {
206206
"hidePanel": true,
207-
"nextSteps": "<a href='/magic-link/check-your-email' class='govuk-back-link'>Back</a><h1 class='govuk-heading-l'>We've sent you another email</h1><p class=\"govuk-body\">We’ve sent another email to {{ email }}. <br><br> Click the link in the email to continue to report an outbreak. </p><h3 class=\"govuk-heading-m\">If you've not received an email</h3><p class=\"govuk-body\">Check your spam or junk folder.<br><br>If you’ve still not received the email in 5 minutes, you need to request a new link.</p><a href='/magic-link' role='button' draggable='false' class='govuk-button' data-module='govuk-button' data-prevent-double-click='true'>Request a new link</button></a>"
207+
"nextSteps": "<a href='/kls-magic-link/check-your-email' class='govuk-back-link'>Back</a><h1 class='govuk-heading-l'>We've sent you another email</h1><p class=\"govuk-body\">We’ve sent another email to {{ email }}. <br><br> Click the link in the email to continue to report an outbreak. </p><h3 class=\"govuk-heading-m\">If you've not received an email</h3><p class=\"govuk-body\">Check your spam or junk folder.<br><br>If you’ve still not received the email in 5 minutes, you need to request a new link.</p><a href='/kls-magic-link' role='button' draggable='false' class='govuk-button' data-module='govuk-button' data-prevent-double-click='true'>Request a new link</button></a>"
208208
}
209209
}
210210
},

runner/src/server/forms/kls-path-1.json

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@
103103
"name": "afZPpL",
104104
"options": {
105105
"customValidationMessages": {
106-
"any.required": "Enter your email address",
107-
"any.only": "Enter your email address",
108-
"string.empty": "Enter your email address"
106+
"any.required": "Enter email address",
107+
"any.only": "Enter email address",
108+
"string.empty": "Enter email address"
109109
}
110110
},
111111
"type": "EmailAddressField",
@@ -313,10 +313,15 @@
313313
{
314314
"name": "etcpxo",
315315
"options": {
316-
"string.empty": "Enter your email address"
316+
"customValidationMessages": {
317+
"any.required": "Enter UK only or international",
318+
"any.only": "Enter UK only or international",
319+
"string.empty": "Enter UK only or international"
320+
}
317321
},
318322
"type": "TextField",
319323
"title": "UK only or international?",
324+
320325
"hint": "Help the KLS team understand the geographic scope of your work by entering the relevant country/countries",
321326
"schema": {}
322327
},
@@ -784,7 +789,13 @@
784789
},
785790
{
786791
"name": "UjGoiE",
787-
"options": {},
792+
"options": {
793+
"customValidationMessages": {
794+
"any.required": "Enter UK only or international",
795+
"any.only": "Enter UK only or international",
796+
"string.empty": "Enter UK only or international"
797+
}
798+
},
788799
"type": "TextField",
789800
"hint": "Help the KLS team understand the geographic scope of your work by entering the relevant country/countries",
790801
"title": "UK only or international?",
@@ -905,8 +916,9 @@
905916
"name": "nmlFzr",
906917
"options": {
907918
"customValidationMessages": {
908-
"any.required": "Enter your group",
909-
"any.only": "Enter your group"
919+
"any.required": "Enter group",
920+
"any.only": "Enter group",
921+
"string.empty": "Enter group"
910922
}
911923
},
912924
"type": "SelectField",
@@ -921,8 +933,10 @@
921933
"name": "oUmeSI",
922934
"options": {
923935
"customValidationMessages": {
924-
"any.required": "Enter your directorate",
925-
"any.only": "Enter your directorate"
936+
"any.required": "Enter directorate",
937+
"any.only": "Enter directorate",
938+
"string.empty": "Enter directorate"
939+
926940
}
927941
},
928942
"type": "SelectField",
@@ -937,8 +951,9 @@
937951
"name": "EkwRix",
938952
"options": {
939953
"customValidationMessages": {
940-
"any.required": "Enter your location",
941-
"any.only": "Enter your location"
954+
"any.required": "Enter location",
955+
"any.only": "Enter location",
956+
"string.empty": "Enter location"
942957
}
943958
},
944959
"type": "SelectField",
@@ -953,9 +968,9 @@
953968
"name": "SPKrpE",
954969
"options": {
955970
"customValidationMessages": {
956-
"any.required": "Enter your email address",
957-
"any.only": "Enter your email address",
958-
"string.empty": "Enter your email address"
971+
"any.required": "Enter email address",
972+
"any.only": "Enter email address",
973+
"string.empty": "Enter email address"
959974
}
960975
},
961976
"type": "EmailAddressField",
@@ -996,9 +1011,9 @@
9961011
"name": "PIjqqt",
9971012
"options": {
9981013
"customValidationMessages": {
999-
"any.required": "Enter your email address",
1000-
"any.only": "Enter your email address",
1001-
"string.empty": "Enter your email address"
1014+
"any.required": "Enter email address",
1015+
"any.only": "Enter email address",
1016+
"string.empty": "Enter email address"
10021017
}
10031018
},
10041019
"type": "EmailAddressField",
@@ -1016,8 +1031,10 @@
10161031
"name": "oCVslj",
10171032
"options": {
10181033
"customValidationMessages": {
1019-
"any.required": "Enter your location",
1020-
"any.only": "Enter your location"
1034+
"any.required": "Enter location",
1035+
"any.only": "Enter location",
1036+
"string.empty": "Enter location"
1037+
10211038
}
10221039
},
10231040
"type": "SelectField",
@@ -1124,18 +1141,8 @@
11241141
},
11251142
{
11261143
"description": "",
1127-
"text": "CSO: Radiation",
1128-
"value": "CSO: Radiation"
1129-
},
1130-
{
1131-
"description": "",
1132-
"text": "Chemicals",
1133-
"value": "Chemicals"
1134-
},
1135-
{
1136-
"value": "Climate and Environmental Hazards",
1137-
"description": "",
1138-
"text": "Climate and Environmental Hazards"
1144+
"text": "CSO: Radiation, Chemicals, Climate and Environmental Hazards",
1145+
"value": "CSO: Radiation, Chemicals, Climate and Environmental Hazards"
11391146
},
11401147
{
11411148
"value": "CSO: Scientific Facilities and Performance",
@@ -1148,14 +1155,9 @@
11481155
"text": "CSO: Science Strategy and Evidence"
11491156
},
11501157
{
1151-
"value": "CMA: Emergency Preparedness",
1152-
"description": "",
1153-
"text": "CMA: Emergency Preparedness"
1154-
},
1155-
{
1156-
"value": "Resilience and Response (EPRR) and Response Operations",
1158+
"value": "CMA: Emergency Preparedness, Resilience and Response (EPRR) and Response Operations",
11571159
"description": "",
1158-
"text": "Resilience and Response (EPRR) and Response Operations"
1160+
"text": "CMA: Emergency Preparedness, Resilience and Response (EPRR) and Response Operations"
11591161
},
11601162
{
11611163
"description": "",
@@ -1188,14 +1190,9 @@
11881190
"text": "CDO: Analysis and Intelligence Assessment"
11891191
},
11901192
{
1191-
"value": "CDO: Data Protection",
1192-
"description": "",
1193-
"text": "CDO: Data Protection"
1194-
},
1195-
{
1196-
"value": "Security and Technology Services",
1193+
"value": "CDO: Data Protection, Security and Technology Services",
11971194
"description": "",
1198-
"text": "Security and Technology Services"
1195+
"text": "CDO: Data Protection, Security and Technology Services"
11991196
},
12001197
{
12011198
"value": "CDO: Digital and Data",

runner/src/server/plugins/engine/pageControllers/MagicLinkController.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { HapiRequest, HapiResponseToolkit } from "server/types";
55
import { validateHmac } from "src/server/utils/hmac";
66
import Jwt from "@hapi/jwt";
77
import config from "server/config";
8+
import { configureEnginePlugin } from "../configureEnginePlugin";
89

910
export class MagicLinkController extends PageController {
1011
constructor(model, pageDef) {
@@ -18,18 +19,22 @@ export class MagicLinkController extends PageController {
1819
const requestTime = request.query.request_time;
1920
const hmacKey = this.model.def.outputs[0].outputConfiguration.hmacKey;
2021

22+
debugger;
23+
2124
const validation = await validateHmac(email, hmac, requestTime, hmacKey);
2225

2326
const { cacheService } = request.services([]);
2427

2528
const state = await cacheService.getState(request);
2629

30+
//💣 Issue: As the program scales, this will need updating on a per-form basis.
31+
// Otherwise active on one form, will mark them active on all.
2732
const isMagicLinkRecordActive = await cacheService.searchForMagicLinkRecord(
2833
email
2934
);
3035

3136
if (!isMagicLinkRecordActive) {
32-
return h.redirect("/magic-link/expired").code(302);
37+
return h.redirect(`/${this.model.basePath}/expired`).code(302);
3338
}
3439

3540
await cacheService.deleteMagicLinkRecord(email);
@@ -38,11 +43,11 @@ export class MagicLinkController extends PageController {
3843
// Handle different invalid token cases
3944
switch (validation.reason) {
4045
case "expired":
41-
return h.redirect("/magic-link/expired").code(302);
46+
return h.redirect(`/${this.model.basePath}/expired`).code(302);
4247
case "invalid_signature":
43-
return h.redirect("/magic-link/incorrect-email").code(302);
48+
return h.redirect(`/${this.model.basePath}/incorrect-email`).code(302);
4449
default:
45-
return h.redirect("/magic-link/error").code(302);
50+
return h.redirect(`/${this.model.basePath}/error`).code(302);
4651
}
4752
}
4853

0 commit comments

Comments
 (0)