Skip to content

Commit b07a58a

Browse files
committed
Updated KLS-Config-v2 and generalised paths for expired magic links
- Reduced bugs in KLS Config - Magic links are now slightly more generalised per magic-config
1 parent cd73f75 commit b07a58a

3 files changed

Lines changed: 44 additions & 53 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: 30 additions & 44 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,7 +313,7 @@
313313
{
314314
"name": "etcpxo",
315315
"options": {
316-
"string.empty": "Enter your email address"
316+
"string.empty": "Enter email address"
317317
},
318318
"type": "TextField",
319319
"title": "UK only or international?",
@@ -905,8 +905,9 @@
905905
"name": "nmlFzr",
906906
"options": {
907907
"customValidationMessages": {
908-
"any.required": "Enter your group",
909-
"any.only": "Enter your group"
908+
"any.required": "Enter group",
909+
"any.only": "Enter group",
910+
"string.empty": "Enter group"
910911
}
911912
},
912913
"type": "SelectField",
@@ -921,8 +922,10 @@
921922
"name": "oUmeSI",
922923
"options": {
923924
"customValidationMessages": {
924-
"any.required": "Enter your directorate",
925-
"any.only": "Enter your directorate"
925+
"any.required": "Enter directorate",
926+
"any.only": "Enter directorate",
927+
"string.empty": "Enter directorate"
928+
926929
}
927930
},
928931
"type": "SelectField",
@@ -937,8 +940,9 @@
937940
"name": "EkwRix",
938941
"options": {
939942
"customValidationMessages": {
940-
"any.required": "Enter your location",
941-
"any.only": "Enter your location"
943+
"any.required": "Enter location",
944+
"any.only": "Enter location",
945+
"string.empty": "Enter location"
942946
}
943947
},
944948
"type": "SelectField",
@@ -953,9 +957,9 @@
953957
"name": "SPKrpE",
954958
"options": {
955959
"customValidationMessages": {
956-
"any.required": "Enter your email address",
957-
"any.only": "Enter your email address",
958-
"string.empty": "Enter your email address"
960+
"any.required": "Enter email address",
961+
"any.only": "Enter email address",
962+
"string.empty": "Enter email address"
959963
}
960964
},
961965
"type": "EmailAddressField",
@@ -996,9 +1000,9 @@
9961000
"name": "PIjqqt",
9971001
"options": {
9981002
"customValidationMessages": {
999-
"any.required": "Enter your email address",
1000-
"any.only": "Enter your email address",
1001-
"string.empty": "Enter your email address"
1003+
"any.required": "Enter email address",
1004+
"any.only": "Enter email address",
1005+
"string.empty": "Enter email address"
10021006
}
10031007
},
10041008
"type": "EmailAddressField",
@@ -1016,8 +1020,10 @@
10161020
"name": "oCVslj",
10171021
"options": {
10181022
"customValidationMessages": {
1019-
"any.required": "Enter your location",
1020-
"any.only": "Enter your location"
1023+
"any.required": "Enter location",
1024+
"any.only": "Enter location",
1025+
"string.empty": "Enter location"
1026+
10211027
}
10221028
},
10231029
"type": "SelectField",
@@ -1124,18 +1130,8 @@
11241130
},
11251131
{
11261132
"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"
1133+
"text": "CSO: Radiation, Chemicals, Climate and Environmental Hazards",
1134+
"value": "CSO: Radiation, Chemicals, Climate and Environmental Hazards"
11391135
},
11401136
{
11411137
"value": "CSO: Scientific Facilities and Performance",
@@ -1148,14 +1144,9 @@
11481144
"text": "CSO: Science Strategy and Evidence"
11491145
},
11501146
{
1151-
"value": "CMA: Emergency Preparedness",
1147+
"value": "CMA: Emergency Preparedness, Resilience and Response (EPRR) and Response Operations",
11521148
"description": "",
1153-
"text": "CMA: Emergency Preparedness"
1154-
},
1155-
{
1156-
"value": "Resilience and Response (EPRR) and Response Operations",
1157-
"description": "",
1158-
"text": "Resilience and Response (EPRR) and Response Operations"
1149+
"text": "CMA: Emergency Preparedness, Resilience and Response (EPRR) and Response Operations"
11591150
},
11601151
{
11611152
"description": "",
@@ -1188,14 +1179,9 @@
11881179
"text": "CDO: Analysis and Intelligence Assessment"
11891180
},
11901181
{
1191-
"value": "CDO: Data Protection",
1192-
"description": "",
1193-
"text": "CDO: Data Protection"
1194-
},
1195-
{
1196-
"value": "Security and Technology Services",
1182+
"value": "CDO: Data Protection, Security and Technology Services",
11971183
"description": "",
1198-
"text": "Security and Technology Services"
1184+
"text": "CDO: Data Protection, Security and Technology Services"
11991185
},
12001186
{
12011187
"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)