Compare commits
114
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9dfa2e8792 | ||
|
|
220d7826b2 | ||
|
|
73419aa598 | ||
|
|
63c56da143 | ||
|
|
ff84e9ea0f | ||
|
|
f4f8075af3 | ||
|
|
3c0a9ef721 | ||
|
|
b821dc2092 | ||
|
|
b15ac5e664 | ||
|
|
fef9591b5d | ||
|
|
4eba824ac2 | ||
|
|
12b0e5eff0 | ||
|
|
57e0c62940 | ||
|
|
bb8c5047c8 | ||
|
|
1377aebc89 | ||
|
|
946d361a67 | ||
|
|
c49b491698 | ||
|
|
bf2e4a3254 | ||
|
|
4b552e9cdd | ||
|
|
b9be188d27 | ||
|
|
71de8a2d14 | ||
|
|
ea5e90943d | ||
|
|
ddcef8f5ea | ||
|
|
f7479b72b9 | ||
|
|
e1f8fb5c96 | ||
|
|
e13700ab65 | ||
|
|
a0a1331a97 | ||
|
|
faf3aa3675 | ||
|
|
9b0cb9adc8 | ||
|
|
93bf7e174f | ||
|
|
8b045ab781 | ||
|
|
fc960f907f | ||
|
|
056dace563 | ||
|
|
9d6d3b9f71 | ||
|
|
0a115a8808 | ||
|
|
706083b6f0 | ||
|
|
431c45ba2b | ||
|
|
eeb4a1f441 | ||
|
|
2badf2e272 | ||
|
|
601668a675 | ||
|
|
d0ce82c69f | ||
|
|
5729625229 | ||
|
|
b59959fb83 | ||
|
|
4829c49c7b | ||
|
|
f8245861b7 | ||
|
|
9d8678f52a | ||
|
|
7649ad3615 | ||
|
|
569faa77e5 | ||
|
|
d9f0c0797d | ||
|
|
500a30e95b | ||
|
|
ebe8cab03f | ||
|
|
16a206ae0f | ||
|
|
b170f65210 | ||
|
|
945f5d4f5d | ||
|
|
07ea9c5451 | ||
|
|
ddf5aba9f5 | ||
|
|
4f1bde2440 | ||
|
|
3a75c69b3a | ||
|
|
3f91a3e095 | ||
|
|
cd0c690454 | ||
|
|
e46b00b4aa | ||
|
|
814d23d3f5 | ||
|
|
c6e6f923a8 | ||
|
|
ba639da696 | ||
|
|
e5bb0477f4 | ||
|
|
38ade33bf3 | ||
|
|
14e8ad82d1 | ||
|
|
7fc6acea5c | ||
|
|
ba83555771 | ||
|
|
99073e2146 | ||
|
|
1c2ae06793 | ||
|
|
4c227da77a | ||
|
|
ef9a630e5e | ||
|
|
7c8b7025a1 | ||
|
|
40d5629ac3 | ||
|
|
127b7c26d4 | ||
|
|
1d01cc4bdb | ||
|
|
be8ee5cfdb | ||
|
|
898e1762bb | ||
|
|
933858ed6c | ||
|
|
ea92d85e6a | ||
|
|
37b8dc7916 | ||
|
|
298fa25c9b | ||
|
|
40092a8915 | ||
|
|
441c9376f4 | ||
|
|
cb24e02ce7 | ||
|
|
adcf017d49 | ||
|
|
697b1adc5f | ||
|
|
41151d987f | ||
|
|
86a3e28d8e | ||
|
|
ba9294ad1a | ||
|
|
16ca736789 | ||
|
|
bb50b17277 | ||
|
|
d417860d1d | ||
|
|
cfbd72e313 | ||
|
|
93eabe8e6d | ||
|
|
ce21a1a00f | ||
|
|
be2df2da8f | ||
|
|
2b691ac4ef | ||
|
|
65616f6307 | ||
|
|
5e98d6e8c2 | ||
|
|
8b607d8134 | ||
|
|
034b59a981 | ||
|
|
37aeb03509 | ||
|
|
0daeb783b9 | ||
|
|
848728584e | ||
|
|
d11c4a868e | ||
|
|
fdeff5b898 | ||
|
|
4e9d585566 | ||
|
|
b95a20a980 | ||
|
|
c9e7743782 | ||
|
|
6bf5918387 | ||
|
|
c2d79cf83f | ||
|
|
6ba1e16f9a |
@@ -1,34 +0,0 @@
|
||||
{
|
||||
"extends": "next/core-web-vitals",
|
||||
"rules": {
|
||||
"@next/next/no-img-element": "off",
|
||||
"react/no-unknown-property": "error"
|
||||
|
||||
}//,
|
||||
//...your configuration
|
||||
// "overrides": [
|
||||
// //...your overrides
|
||||
// {
|
||||
// // Force the setting of a swagger description on each api endpoint
|
||||
// "files": ["pages/api/**/*.js"],
|
||||
// "plugins": ["jsdoc"],
|
||||
// "rules": {
|
||||
// "jsdoc/no-missing-syntax": [
|
||||
// "error",
|
||||
// {
|
||||
// "contexts": [
|
||||
// {
|
||||
// "comment": "JsdocBlock:has(JsdocTag[tag=swagger])",
|
||||
// "context": "any",
|
||||
// "message": "@swagger documentation is required on each API. Check this out for syntax info: https://github.com/jellydn/next-swagger-doc"
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
|
||||
}
|
||||
|
||||
|
||||
+35
-6
@@ -525,6 +525,31 @@ export const deleteBlob = async (containerName, blobName) => {
|
||||
return { "deleted": blobName };
|
||||
};
|
||||
|
||||
const isSafeDeletionPathSegment = (value) =>
|
||||
typeof value === "string" &&
|
||||
value.length > 0 &&
|
||||
value.length <= 255 &&
|
||||
value === value.trim() &&
|
||||
value !== "." &&
|
||||
value !== ".." &&
|
||||
!/[\\/\u0000-\u001f\u007f]/.test(value);
|
||||
|
||||
const buildDeletionFolderPrefix = (resourcePath, expectedSegmentCount) => {
|
||||
if (typeof resourcePath !== "string") {
|
||||
throw new Error("Invalid deletion resource path");
|
||||
}
|
||||
|
||||
const segments = resourcePath.split("/");
|
||||
if (
|
||||
segments.length !== expectedSegmentCount ||
|
||||
!segments.every(isSafeDeletionPathSegment)
|
||||
) {
|
||||
throw new Error("Invalid deletion resource path");
|
||||
}
|
||||
|
||||
return segments.join("/") + "/";
|
||||
};
|
||||
|
||||
export const deleteBlobCase = async (containerName, blobName) => {
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
@@ -538,13 +563,15 @@ export const deleteBlobCase = async (containerName, blobName) => {
|
||||
|
||||
//conLog"deleteBlobCase ");
|
||||
|
||||
console.log("blob to delete:", blobName);
|
||||
const folderPrefix = buildDeletionFolderPrefix(blobName, 1);
|
||||
|
||||
console.log("blob to delete:", folderPrefix);
|
||||
|
||||
for await (const blob of containerClient.listBlobsFlat({
|
||||
prefix: blobName
|
||||
prefix: folderPrefix
|
||||
})) {
|
||||
console.log(" ------ :", blob.name);
|
||||
containerClient.deleteBlob(blob.name);
|
||||
await containerClient.deleteBlob(blob.name);
|
||||
}
|
||||
|
||||
//containerClient.deleteBlob(blobName);
|
||||
@@ -566,17 +593,19 @@ export const deleteBlobRep = async (containerName, blobName) => {
|
||||
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
|
||||
const containerClient = new ContainerClient(sasUrl);
|
||||
|
||||
console.log("blob to delete:", blobName);
|
||||
const folderPrefix = buildDeletionFolderPrefix(blobName, 2);
|
||||
|
||||
console.log("blob to delete:", folderPrefix);
|
||||
|
||||
for await (const blob of containerClient.listBlobsFlat({
|
||||
prefix: blobName
|
||||
prefix: folderPrefix
|
||||
})) {
|
||||
console.log("------ :", blob.name);
|
||||
const blockBlobClient = containerClient.getBlockBlobClient(blob.name);
|
||||
console.log("=======:", await blockBlobClient.exists());
|
||||
|
||||
(await blockBlobClient.exists()) &&
|
||||
containerClient.deleteBlob(blob.name);
|
||||
(await containerClient.deleteBlob(blob.name));
|
||||
|
||||
//containerClient.deleteIfExists();
|
||||
//containerClient.deleteBlob(blob.name);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { getJson, requestJson } from "./endpointClient";
|
||||
import { getSignedJson, postSignedJson } from "./signedRequestClient";
|
||||
|
||||
export const getFileJson = (url) => {
|
||||
return getJson(url);
|
||||
export const getFileJson = (url, config) => {
|
||||
return getJson(url, config);
|
||||
};
|
||||
|
||||
export const getSignedFileJson = async (queryUrl) => {
|
||||
|
||||
@@ -11,31 +11,6 @@ export const getPersonalAccount = (contactid) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getLogin = (emailAddress, pwd) => {
|
||||
return getJson(
|
||||
"/api/endpoint/getlogin_api?emailAddress=" +
|
||||
emailAddress +
|
||||
"&pwd=" +
|
||||
pwd
|
||||
).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const updatePassword = (contactId, newpassword) => {
|
||||
var queryUrl = "/api/endpoint/updateaccount_api?contactId=" + contactId;
|
||||
var data = { "pinswg_custom_password": newpassword };
|
||||
var config = {
|
||||
method: "post",
|
||||
url: queryUrl,
|
||||
data: data
|
||||
};
|
||||
|
||||
return requestJson(config).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const updateAccount = async (contactId, updateBody, ssr) => {
|
||||
var queryUrl =
|
||||
(ssr ? BASE_URL : "") +
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import {
|
||||
getPersonalAccount,
|
||||
getLogin,
|
||||
updatePassword,
|
||||
updateAccount,
|
||||
createAccount,
|
||||
getEmailAccountCheck,
|
||||
@@ -12,8 +10,6 @@ import {
|
||||
|
||||
export {
|
||||
getPersonalAccount,
|
||||
getLogin,
|
||||
updatePassword,
|
||||
updateAccount,
|
||||
createAccount,
|
||||
getEmailAccountCheck,
|
||||
|
||||
@@ -76,35 +76,6 @@ export const getAppealID = (
|
||||
});
|
||||
};
|
||||
|
||||
export const createNewCase = (
|
||||
appealTypeId,
|
||||
lpaID,
|
||||
contactid,
|
||||
createBody,
|
||||
containerName
|
||||
) => {
|
||||
appealTypeId = parseInt(appealTypeId);
|
||||
|
||||
var data = createBody;
|
||||
|
||||
var queryUrl = buildFileQuery("/api/endpoint/createcase_api", {
|
||||
appealTypeId,
|
||||
lpaID,
|
||||
contactid,
|
||||
containername: containerName
|
||||
});
|
||||
|
||||
var config = {
|
||||
method: "post",
|
||||
url: withBaseUrl(BASE_URL, queryUrl),
|
||||
data: data
|
||||
};
|
||||
|
||||
return requestJson(config).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const createNewCaseBlob = (
|
||||
appealTypeId,
|
||||
lpaID,
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
getSIPSEvents,
|
||||
getSIPSMedia,
|
||||
getAppealID,
|
||||
createNewCase,
|
||||
createNewCaseBlob,
|
||||
updateCase,
|
||||
updateCaseBlob,
|
||||
@@ -26,7 +25,6 @@ export {
|
||||
getSIPSEvents,
|
||||
getSIPSMedia,
|
||||
getAppealID,
|
||||
createNewCase,
|
||||
createNewCaseBlob,
|
||||
updateCase,
|
||||
updateCaseBlob,
|
||||
|
||||
@@ -28,13 +28,48 @@ export const getAwaitingSubmissionFromBlob = (containerName) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getRepsFromBlob = (containerName) => {
|
||||
export const getRepsFromBlob = (containerName, config) => {
|
||||
const route = buildFileQuery("/api/file/getrepsblob", {
|
||||
container: containerName
|
||||
});
|
||||
|
||||
const url = withBaseUrl(BASE_URL, appendHashSuffix(route, hashAPIPath));
|
||||
|
||||
const hasForwardedCookie =
|
||||
typeof config?.headers?.Cookie === "string" &&
|
||||
config.headers.Cookie.length > 0;
|
||||
|
||||
if (hasForwardedCookie) {
|
||||
let trustedDestination = false;
|
||||
|
||||
try {
|
||||
const destination = new URL(url);
|
||||
const expectedOrigin = new URL(process.env.NEXTAUTH_URL);
|
||||
|
||||
trustedDestination =
|
||||
destination.origin === expectedOrigin.origin &&
|
||||
["http:", "https:"].includes(destination.protocol) &&
|
||||
!destination.username &&
|
||||
!destination.password;
|
||||
} catch {
|
||||
trustedDestination = false;
|
||||
}
|
||||
|
||||
if (!trustedDestination) {
|
||||
return Promise.reject(
|
||||
new Error("Untrusted representation request destination")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return getFileJson(
|
||||
withBaseUrl(BASE_URL, appendHashSuffix(route, hashAPIPath))
|
||||
url,
|
||||
hasForwardedCookie
|
||||
? {
|
||||
...config,
|
||||
maxRedirects: 0
|
||||
}
|
||||
: config
|
||||
).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
@@ -83,7 +118,7 @@ export const deleteAwaitingSubmissionsFromBlob = (
|
||||
casefolderID
|
||||
});
|
||||
|
||||
return getSignedFileJson(queryUrl).catch((error) => {
|
||||
return postSignedFileJson(queryUrl).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
@@ -99,7 +134,7 @@ export const deleteMyRepresentationsFromBlob = (
|
||||
repfile
|
||||
});
|
||||
|
||||
return getSignedFileJson(queryUrl).catch((error) => {
|
||||
return postSignedFileJson(queryUrl).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -25,3 +25,44 @@ export const sendEmail = async (
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const sendContactUsConfirmation = async (formValues, language) => {
|
||||
const mailData = {
|
||||
"contactEmail": formValues.contactEmail,
|
||||
"contactSubject": formValues.contactSubject,
|
||||
"contactbody": formValues.contactbody,
|
||||
"typeOfContact": formValues.typeOfContact,
|
||||
"language": language
|
||||
};
|
||||
|
||||
try {
|
||||
return await requestJson({
|
||||
method: "post",
|
||||
url: "/api/email/contactus-confirmation",
|
||||
data: mailData
|
||||
});
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const sendContactUsPETNotification = async (formValues) => {
|
||||
const mailData = {
|
||||
"contactEmail": formValues.contactEmail,
|
||||
"contactSubject": formValues.contactSubject,
|
||||
"contactbody": formValues.contactbody,
|
||||
"typeOfContact": formValues.typeOfContact
|
||||
};
|
||||
|
||||
try {
|
||||
return await requestJson({
|
||||
method: "post",
|
||||
url: "/api/email/contactus-pet-notification",
|
||||
data: mailData
|
||||
});
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -144,24 +144,6 @@ export const createWatchedCases = async (formValues) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteMyRepresentations = (myRepresentationsID) => {
|
||||
var queryUrl = buildFileQuery("/api/endpoint/deletemyrepresentations_api", {
|
||||
myRepresentationsID
|
||||
});
|
||||
|
||||
return deleteSignedJson(queryUrl, {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json;odata.metadata=none",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteAwaitingSubmissions = (incidentID) => {
|
||||
var queryUrl = buildFileQuery(
|
||||
"/api/endpoint/deleteawaitingsubmissions_api",
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
getAwaitingSubmissionProxy,
|
||||
createWatchedCases,
|
||||
deleteWatchedCases,
|
||||
deleteMyRepresentations,
|
||||
deleteAwaitingSubmissions,
|
||||
sendCaseCompleteMessage,
|
||||
sendCaseCompleteMessageProxy,
|
||||
@@ -35,7 +34,6 @@ export {
|
||||
getAwaitingSubmissionProxy,
|
||||
createWatchedCases,
|
||||
deleteWatchedCases,
|
||||
deleteMyRepresentations,
|
||||
deleteAwaitingSubmissions,
|
||||
sendCaseCompleteMessage,
|
||||
sendCaseCompleteMessageProxy,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import { parseCookies, setCookie } from "nookies";
|
||||
import { parseCookies, setCookie } from "../lib/cookies";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
const COOKIE_NAME = "pedwAiPolicyNoticeHidden";
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import React, { useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { Field, formValueSelector, reduxForm } from "redux-form";
|
||||
import { updatePassword } from "../../actions/services/accountService";
|
||||
|
||||
const RenderTextfield = ({
|
||||
id,
|
||||
className,
|
||||
rows,
|
||||
datafieldname,
|
||||
name,
|
||||
label,
|
||||
input,
|
||||
type,
|
||||
errorMsg,
|
||||
meta: { touched, error },
|
||||
...custom
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={
|
||||
touched && error
|
||||
? "govuk-form-group govuk-form-group--error"
|
||||
: "govuk-form-group "
|
||||
}
|
||||
>
|
||||
<label className="govuk-label " htmlFor={id} id={id + "_label"}>
|
||||
{label}
|
||||
</label>
|
||||
{touched && error && (
|
||||
<span id={id + "-error"} className="govuk-error-message">
|
||||
<span className="govuk-visually-hidden">Error:</span>{" "}
|
||||
{touched &&
|
||||
((error && (
|
||||
<span>{errorMsg ? errorMsg : error}</span>
|
||||
)) ||
|
||||
(warning && <span>{warning}</span>))}
|
||||
</span>
|
||||
)}
|
||||
<input
|
||||
{...input}
|
||||
className={className}
|
||||
name={name}
|
||||
id={id}
|
||||
type={type}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const ChangePassword = (props) => {
|
||||
const {
|
||||
footerLinks,
|
||||
pages,
|
||||
handleSubmit,
|
||||
value,
|
||||
setPasswordUpdated,
|
||||
passwordUpdated
|
||||
} = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
|
||||
let errorsobj = {};
|
||||
|
||||
const onHandleSubmit = (values) => {
|
||||
let contactid = props.props.accountDetails.loggedinUserId;
|
||||
let updateBody = props.props.form.changepasswordForm.values.newpassword;
|
||||
console.log(contactid, updateBody);
|
||||
updatePassword(contactid, updateBody);
|
||||
setPasswordUpdated(true);
|
||||
};
|
||||
|
||||
const required = (value) => (value ? undefined : "Is required");
|
||||
|
||||
const passwordsMustMatch = (value, allValues) =>
|
||||
value !== allValues.newpassword ? "Passwords do not match" : undefined;
|
||||
|
||||
const minLength = (min) => (value) =>
|
||||
value && value.length < min
|
||||
? `Must be at least ${min} characters`
|
||||
: undefined;
|
||||
|
||||
const [hasErrors, setHasErrors] = useState("");
|
||||
|
||||
return (
|
||||
<>
|
||||
{passwordUpdated != true ? (
|
||||
<form onSubmit={handleSubmit(onHandleSubmit)}>
|
||||
<fieldset className="govuk-fieldset">
|
||||
<Field
|
||||
name="newpassword"
|
||||
id="newpassword"
|
||||
component={RenderTextfield}
|
||||
type="password"
|
||||
className="govuk-input govuk-input--width-20"
|
||||
validate={[required, minLength(6)]}
|
||||
label="New password"
|
||||
/>
|
||||
<Field
|
||||
name="confirmpassword"
|
||||
id="confirmpassword"
|
||||
component={RenderTextfield}
|
||||
type="password"
|
||||
className="govuk-input govuk-input--width-20"
|
||||
validate={[required, passwordsMustMatch]}
|
||||
label="Confirm new password"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<div className="govuk-button-group">
|
||||
<button
|
||||
type="submit"
|
||||
className="govuk-button"
|
||||
data-module="govuk-button"
|
||||
>
|
||||
Continue
|
||||
</button>
|
||||
<Link
|
||||
href={
|
||||
"/myportal?q=" +
|
||||
props.accountDetails.loggedinUserId
|
||||
}
|
||||
className="govuk-link"
|
||||
>
|
||||
Cancel
|
||||
</Link>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<>
|
||||
<p className="govuk-body">
|
||||
<Link
|
||||
href={
|
||||
"/myportal?q=" +
|
||||
props.accountDetails.loggedinUserId
|
||||
}
|
||||
className="govuk-link"
|
||||
>
|
||||
Go to My Portal
|
||||
</Link>
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
search: state.search,
|
||||
searchResultsObj: state.searchResultsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
accountDetails: state.accountDetails
|
||||
//form: state.form,
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
setCurrentSection: (currentSection) => {
|
||||
dispatch(setCurrentSection(currentSection));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const selector = formValueSelector("changepasswordForm"); // <-- same as form name
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(
|
||||
reduxForm({
|
||||
form: "changepasswordForm",
|
||||
destroyOnUnmount: false
|
||||
})(ChangePassword)
|
||||
);
|
||||
@@ -4,7 +4,7 @@ import { useRouter } from "next/router";
|
||||
import React, { useEffect } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { updateAccount } from "../../actions/services/accountService";
|
||||
import { setCookie } from "nookies";
|
||||
import { setCookie } from "../../lib/cookies";
|
||||
|
||||
const PersonalDetailsComplete = (props) => {
|
||||
const {
|
||||
|
||||
@@ -92,11 +92,6 @@ const RegisterForm = (props) => {
|
||||
? "Invalid phone number"
|
||||
: undefined;
|
||||
|
||||
const passwordsMatch = (value, allValues) =>
|
||||
value !== allValues.pinswg_custom_password
|
||||
? "Passwords don't match"
|
||||
: undefined;
|
||||
|
||||
const minLength = (min) => (value) =>
|
||||
value && value.length < min
|
||||
? `Must be ${min} characters or more`
|
||||
|
||||
@@ -2,13 +2,6 @@
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { bytesToSize } from "../../../components/utils";
|
||||
import {
|
||||
deleteMyRepresentationsFromBlob,
|
||||
deleteAwaitingSubmissionsFromBlob,
|
||||
getRepsFromBlobProxy
|
||||
} from "../../../actions/services/documentService";
|
||||
import { sendRepCompleteMessage } from "../../../actions/services/portalService";
|
||||
import { parseCookies } from "nookies";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
|
||||
import { formatBlobDates } from "../utils/adminHelper";
|
||||
@@ -25,15 +18,38 @@ export default function StorageTab({ data, repCompleteCount }) {
|
||||
};
|
||||
|
||||
const deleteRepItem = (containerID, caseID, repfile) => {
|
||||
let cookies = parseCookies();
|
||||
//console.log("sssss", containerID, caseID, repfile);
|
||||
|
||||
deleteMyRepresentationsFromBlob(containerID, caseID, repfile)
|
||||
fetch("/api/admin/deleteblobrep", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
container: containerID,
|
||||
casefolderID: caseID,
|
||||
repfile
|
||||
})
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error("Unable to delete representation");
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
return data;
|
||||
})
|
||||
.then(() => {
|
||||
getRepsFromBlobProxy(containerID)
|
||||
fetch("/api/admin/getrepsblobproxy", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ container: containerID })
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
"Unable to refresh representations"
|
||||
);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
setMyRepresentations(data);
|
||||
setMyRepresentationsDetails(data);
|
||||
@@ -48,6 +64,9 @@ export default function StorageTab({ data, repCompleteCount }) {
|
||||
"viewKey": "myRepresentations"
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -116,20 +135,52 @@ export default function StorageTab({ data, repCompleteCount }) {
|
||||
{folder.hasTmpFile && (
|
||||
<>
|
||||
<button
|
||||
onClick={() => {
|
||||
confirm(
|
||||
"Do you want to remove this unsubmitted appeal " +
|
||||
folder.folderPath +
|
||||
"?\n"
|
||||
) &&
|
||||
(deleteCaseItem(
|
||||
c.container,
|
||||
folder.folderPath,
|
||||
setData
|
||||
),
|
||||
onClick={async () => {
|
||||
if (
|
||||
!confirm(
|
||||
"Do you want to remove this unsubmitted appeal " +
|
||||
folder.folderPath +
|
||||
"?\n"
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response =
|
||||
await fetch(
|
||||
"/api/admin/deleteblobcase",
|
||||
{
|
||||
method: "POST",
|
||||
headers:
|
||||
{
|
||||
"Content-Type":
|
||||
"application/json"
|
||||
},
|
||||
body: JSON.stringify(
|
||||
{
|
||||
container:
|
||||
c.container,
|
||||
casefolderID:
|
||||
folder.folderPath
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
"Unable to delete case"
|
||||
);
|
||||
}
|
||||
|
||||
alert(
|
||||
"Temp case Deleted!"
|
||||
));
|
||||
);
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Delete this TMP appeal
|
||||
@@ -174,7 +225,7 @@ export default function StorageTab({ data, repCompleteCount }) {
|
||||
onClick={async () => {
|
||||
const response =
|
||||
await fetch(
|
||||
"/api/file/editRepJson",
|
||||
"/api/admin/editRepJson",
|
||||
{
|
||||
method: "POST",
|
||||
headers:
|
||||
@@ -216,7 +267,8 @@ export default function StorageTab({ data, repCompleteCount }) {
|
||||
{folder.repComplete && (
|
||||
<button
|
||||
onClick={async () => {
|
||||
confirm(
|
||||
if (
|
||||
!confirm(
|
||||
"Do you want resend the rep queue message " +
|
||||
folder.repJsonBlob.name.split(
|
||||
"/"
|
||||
@@ -225,20 +277,53 @@ export default function StorageTab({ data, repCompleteCount }) {
|
||||
folder.repJsonBlob.name.split(
|
||||
"/"
|
||||
)[1]
|
||||
) &&
|
||||
(sendRepCompleteMessage(
|
||||
c.container,
|
||||
folder.repJsonBlob.name.split(
|
||||
"/"
|
||||
)[0],
|
||||
folder.repJsonBlob.name.split(
|
||||
"/"
|
||||
)[1]
|
||||
),
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response =
|
||||
await fetch(
|
||||
"/api/admin/createrepcompletemessage",
|
||||
{
|
||||
method: "POST",
|
||||
headers:
|
||||
{
|
||||
"Content-Type":
|
||||
"application/json"
|
||||
},
|
||||
body: JSON.stringify(
|
||||
{
|
||||
container:
|
||||
c.container,
|
||||
tempcaseref:
|
||||
folder.repJsonBlob.name.split(
|
||||
"/"
|
||||
)[0],
|
||||
repid: folder.repJsonBlob.name.split(
|
||||
"/"
|
||||
)[1]
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
"Unable to recreate representation queue message"
|
||||
);
|
||||
}
|
||||
|
||||
alert(
|
||||
"rep queue message sent!"
|
||||
),
|
||||
window.location.reload());
|
||||
);
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
consoleLogger(
|
||||
error
|
||||
);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Recreate Queue Message
|
||||
|
||||
@@ -297,7 +297,7 @@ let MakeRepresentation = (props) => {
|
||||
});
|
||||
|
||||
let resultsObj = findResultsObjForCurrentReference({
|
||||
"currentReference": currentView.caseReference.currentReference,
|
||||
"currentReference": currentView.caseReference.ticketnumber,
|
||||
"caseResultsSource": caseResultsSource
|
||||
});
|
||||
|
||||
|
||||
@@ -33,6 +33,14 @@ export const buildSubmitEnrichedValues = ({
|
||||
representationCapacity,
|
||||
locale
|
||||
}) => {
|
||||
const isPopulatedText = (value) =>
|
||||
value !== null &&
|
||||
value !== undefined &&
|
||||
(typeof value !== "string" || value.trim() !== "");
|
||||
|
||||
const preserveExistingWhenMissing = (canonicalValue, existingValue) =>
|
||||
isPopulatedText(canonicalValue) ? canonicalValue : existingValue;
|
||||
|
||||
const buildSiteAddress = () => {
|
||||
const {
|
||||
pinswg_siteaddressline1,
|
||||
@@ -47,10 +55,12 @@ export const buildSubmitEnrichedValues = ({
|
||||
pinswg_siteaddresstown,
|
||||
pinswg_siteaddresspostcode
|
||||
]
|
||||
.filter(Boolean)
|
||||
.filter(isPopulatedText)
|
||||
.join(" ");
|
||||
};
|
||||
|
||||
const siteAddress = buildSiteAddress();
|
||||
|
||||
return {
|
||||
...formValues,
|
||||
containerID: accountDetails.containerID,
|
||||
@@ -58,7 +68,10 @@ export const buildSubmitEnrichedValues = ({
|
||||
incidentID:
|
||||
caseReferenceObj.incidentid ||
|
||||
caseReferenceObj.repDetails.incidentid,
|
||||
caseRef: caseReferenceObj.ticketnumber,
|
||||
caseRef: preserveExistingWhenMissing(
|
||||
caseReferenceObj.ticketnumber,
|
||||
formValues.caseRef
|
||||
),
|
||||
casereference: caseReferenceObj.currentReference,
|
||||
pinswg_questionnaireduedate: detailsObj.pinswg_questionnaireduedate,
|
||||
pinswg_endofrepresentationperiod:
|
||||
@@ -72,12 +85,18 @@ export const buildSubmitEnrichedValues = ({
|
||||
firstname: accountDetails.firstname,
|
||||
lastname: accountDetails.lastname,
|
||||
emailAddress: accountDetails.emailaddress1,
|
||||
siteAddress: buildSiteAddress(),
|
||||
siteAddress: preserveExistingWhenMissing(
|
||||
siteAddress,
|
||||
formValues.siteAddress
|
||||
),
|
||||
pinswg_siteaddressline1: detailsObj.pinswg_siteaddressline1,
|
||||
pinswg_siteaddressline2: detailsObj.pinswg_siteaddressline2,
|
||||
pinswg_siteaddresstown: detailsObj.pinswg_siteaddresstown,
|
||||
pinswg_siteaddresspostcode: detailsObj.pinswg_siteaddresspostcode,
|
||||
pinswg_lpareference: resultsObj?.pinswg_lpareference,
|
||||
pinswg_lpareference: preserveExistingWhenMissing(
|
||||
resultsObj?.pinswg_lpareference,
|
||||
formValues.pinswg_lpareference
|
||||
),
|
||||
_pinswg_appellant_value: detailsObj._pinswg_appellant_value,
|
||||
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue":
|
||||
detailsObj[
|
||||
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
} from "../../store/watchedCases/action";
|
||||
|
||||
import { signIn, useSession } from "next-auth/react";
|
||||
import { destroyCookie, parseCookies, setCookie } from "nookies";
|
||||
import { destroyCookie, parseCookies, setCookie } from "../../lib/cookies";
|
||||
import { getFormCollectionByID, getDetailsProxy, hasOwn } from "../utils";
|
||||
import {
|
||||
getLivePublishedEvent,
|
||||
@@ -877,6 +877,52 @@ const CaseSummary = (props) => {
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<div className="">
|
||||
{getFormCollectionByID(
|
||||
appealTypeID
|
||||
).PrimaryIdAttribute ==
|
||||
"pinswg_sipscase" &&
|
||||
isConsultationWindowOpen(
|
||||
detailsObj
|
||||
) && (
|
||||
<p>
|
||||
{t(
|
||||
"case:summary-make-consultation-response-para-a"
|
||||
)}
|
||||
<Link
|
||||
target="_blank"
|
||||
className="govuk-link"
|
||||
href={t(
|
||||
"case:summary-make-representation-para-a-link"
|
||||
)}
|
||||
>
|
||||
{t(
|
||||
"case:summary-make-representation-para-a-label"
|
||||
)}
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
{isGeneralRepresentationWindowOpen(
|
||||
detailsObj
|
||||
) && (
|
||||
<div className="govuk-button-group">
|
||||
<p>
|
||||
{t(
|
||||
"case:summary-make-representation-para-a"
|
||||
)}
|
||||
<Link
|
||||
target="_blank"
|
||||
className="govuk-link"
|
||||
href={t(
|
||||
"case:summary-make-representation-para-a-link"
|
||||
)}
|
||||
>
|
||||
{t(
|
||||
"case:summary-make-representation-para-a-label"
|
||||
)}
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<div className="govuk-button-group">
|
||||
{getFormCollectionByID(
|
||||
appealTypeID
|
||||
@@ -983,6 +1029,7 @@ const CaseSummary = (props) => {
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{isGeneralRepresentationWindowOpen(
|
||||
detailsObj
|
||||
) && (
|
||||
|
||||
@@ -2,6 +2,7 @@ import _ from "lodash";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import { useRouter } from "next/router";
|
||||
import transLookup from "../../../data/lookuptranslations.json";
|
||||
import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue";
|
||||
import SummaryCard from "../summary/components/SummaryCard";
|
||||
import SummaryRow from "../summary/components/SummaryRow";
|
||||
import { hasOwn } from "../../utils";
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useRouter } from "next/router";
|
||||
import transLookup from "../../../data/lookuptranslations.json";
|
||||
import SummaryCard from "../summary/components/SummaryCard";
|
||||
import SummaryRow from "../summary/components/SummaryRow";
|
||||
import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue";
|
||||
import { hasOwn } from "../../utils";
|
||||
|
||||
const Pinswg_transportandworkactid = (props) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { signOut } from "next-auth/react";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import { useRouter } from "next/router";
|
||||
import { useState, useEffect } from "react";
|
||||
import { destroyCookie, parseCookies, setCookie } from "nookies";
|
||||
import { destroyCookie, parseCookies, setCookie } from "../../lib/cookies";
|
||||
import { signIn, useSession } from "next-auth/react";
|
||||
|
||||
const WatchModal = (props) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { parseCookies } from "nookies";
|
||||
import { parseCookies } from "../../lib/cookies";
|
||||
import { useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { reduxForm } from "redux-form";
|
||||
|
||||
+27
-14
@@ -108,7 +108,7 @@ export default function Footer(props) {
|
||||
>
|
||||
<span className="vo_hidden">
|
||||
{t(
|
||||
"common:social-bar-share-via-link",
|
||||
"common:social-bar-share-via-link"
|
||||
)}{" "}
|
||||
</span>
|
||||
Twitter
|
||||
@@ -186,37 +186,37 @@ export default function Footer(props) {
|
||||
<li className="govuk-footer__inline-list-item govuk-!-font-weight-bold govuk-!-margin-right-7">
|
||||
<a
|
||||
href={t(
|
||||
"common:footer-guidance-link",
|
||||
"common:footer-guidance-link"
|
||||
)}
|
||||
className="nav-link"
|
||||
>
|
||||
{t(
|
||||
"common:footer-guidance-link-label",
|
||||
"common:footer-guidance-link-label"
|
||||
)}
|
||||
</a>
|
||||
</li>
|
||||
<li className="govuk-footer__inline-list-item govuk-!-font-weight-bold govuk-!-margin-right-7">
|
||||
<a
|
||||
href={t(
|
||||
"common:footer-announcements-link",
|
||||
"common:footer-announcements-link"
|
||||
)}
|
||||
className="nav-link"
|
||||
>
|
||||
{t(
|
||||
"common:footer-announcements-link-label",
|
||||
"common:footer-announcements-link-label"
|
||||
)}
|
||||
</a>
|
||||
</li>
|
||||
<li className="govuk-footer__inline-list-item govuk-!-font-weight-bold">
|
||||
<a
|
||||
href={t(
|
||||
"common:footer-contact-us-link",
|
||||
"common:footer-contact-us-link"
|
||||
)}
|
||||
className="govuk-footer__link"
|
||||
id="aContactUs"
|
||||
>
|
||||
{t(
|
||||
"common:footer-contact-us-link-label",
|
||||
"common:footer-contact-us-link-label"
|
||||
)}
|
||||
</a>
|
||||
</li>
|
||||
@@ -236,7 +236,7 @@ export default function Footer(props) {
|
||||
id="aAccessibility"
|
||||
>
|
||||
{t(
|
||||
"common:footer-accessibility-link-label",
|
||||
"common:footer-accessibility-link-label"
|
||||
)}
|
||||
</Link>
|
||||
</li>
|
||||
@@ -257,13 +257,13 @@ export default function Footer(props) {
|
||||
<li className="govuk-footer__inline-list-item">
|
||||
<a
|
||||
href={t(
|
||||
"common:footer-copyright-link",
|
||||
"common:footer-copyright-link"
|
||||
)}
|
||||
className="govuk-footer__link"
|
||||
id="Access"
|
||||
>
|
||||
{t(
|
||||
"common:footer-copyright-link-label",
|
||||
"common:footer-copyright-link-label"
|
||||
)}
|
||||
</a>
|
||||
</li>
|
||||
@@ -271,13 +271,13 @@ export default function Footer(props) {
|
||||
<li className="govuk-footer__inline-list-item">
|
||||
<Link
|
||||
href={t(
|
||||
"common:footer-privacy-link",
|
||||
"common:footer-privacy-link"
|
||||
)}
|
||||
id="aPrivacy"
|
||||
className="govuk-footer__link"
|
||||
>
|
||||
{t(
|
||||
"common:footer-privacy-link-label",
|
||||
"common:footer-privacy-link-label"
|
||||
)}
|
||||
</Link>
|
||||
</li>
|
||||
@@ -285,13 +285,26 @@ export default function Footer(props) {
|
||||
<li className="govuk-footer__inline-list-item">
|
||||
<Link
|
||||
href={t(
|
||||
"common:footer-terms-conditions-link",
|
||||
"common:footer-terms-conditions-link"
|
||||
)}
|
||||
id="aTermsConds"
|
||||
className="govuk-footer__link"
|
||||
>
|
||||
{t(
|
||||
"common:footer-terms-conditions-link-label",
|
||||
"common:footer-terms-conditions-link-label"
|
||||
)}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-footer__inline-list-item">
|
||||
<Link
|
||||
href={t(
|
||||
"common:footer-pedw-use-ai-link"
|
||||
)}
|
||||
id="aHowToAI"
|
||||
className="govuk-footer__link"
|
||||
>
|
||||
{t(
|
||||
"common:footer-pedw-use-ai-label"
|
||||
)}
|
||||
</Link>
|
||||
</li>
|
||||
|
||||
@@ -2,7 +2,7 @@ import _ from "lodash";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { destroyCookie, setCookie } from "nookies";
|
||||
import { destroyCookie, setCookie } from "../lib/cookies";
|
||||
import { connect } from "react-redux";
|
||||
import Banner from "../components/banner";
|
||||
import { setLogout } from "../store/accountDetails/action";
|
||||
|
||||
@@ -2,7 +2,7 @@ import useTranslation from "next-translate/useTranslation";
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { parseCookies } from "nookies";
|
||||
import { parseCookies } from "../../lib/cookies";
|
||||
import { setLoggedInUserId } from "../../store/accountDetails/action";
|
||||
import { signOut, useSession } from "next-auth/react";
|
||||
import CaseComment from "./casecomment";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { parseCookies } from "nookies";
|
||||
import { parseCookies } from "../../lib/cookies";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
deleteAwaitingSubmissionsFromBlob,
|
||||
@@ -70,7 +70,7 @@ const AwaitingSubmissionFromBlob = (props) => {
|
||||
|
||||
const deleteCaseItem = (containerID, caseID) => {
|
||||
let cookies = parseCookies();
|
||||
console.log("sssss", containerID, caseID);
|
||||
//console.log("sssss", containerID, caseID);
|
||||
|
||||
deleteAwaitingSubmissionsFromBlob(containerID, caseID)
|
||||
.then((data) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import _ from "lodash";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { parseCookies } from "nookies";
|
||||
import { parseCookies } from "../../lib/cookies";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
deleteAwaitingSubmissions,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { parseCookies } from "nookies";
|
||||
import { parseCookies } from "../../lib/cookies";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
deleteAwaitingSubmissions,
|
||||
|
||||
@@ -3,7 +3,7 @@ import _ from "lodash";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { parseCookies } from "nookies";
|
||||
import { parseCookies } from "../../lib/cookies";
|
||||
import { useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
|
||||
@@ -27,24 +27,6 @@ export default function YourAccount() {
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* <div className="card-body">
|
||||
<h3 className="heading-small card-heading">
|
||||
{t("myportal:changepassword-card-title")}
|
||||
</h3>
|
||||
<p className="govuk-body-s">
|
||||
{" "}
|
||||
{t("myportal:changepassword-card-paragraph-one")}
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<Link href="/account/changepassword">
|
||||
<a className="govuk-button-secondary">
|
||||
{t("myportal:changepassword-card-link")}
|
||||
</a>
|
||||
</Link>
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -393,13 +393,6 @@ let CreateCase = (props) => {
|
||||
|
||||
delete values.confirmHASCAS;
|
||||
|
||||
// createNewCase(
|
||||
// appTypeCollection.appealTypeID,
|
||||
// values.lpaTypes,
|
||||
// props.loggedInUser,
|
||||
// values,
|
||||
// props.containerID
|
||||
// )
|
||||
const selectedLpaName = props.LPAData.LPAData.value.filter((obj) => {
|
||||
return obj.accountid === values.lpaTypes;
|
||||
})[0].name;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { connect } from "react-redux";
|
||||
import transLookup from "../../data/lookuptranslations.json";
|
||||
import { setCurrentReference } from "../../store/currentView/action";
|
||||
|
||||
import { parseCookies, setCookie } from "nookies";
|
||||
import { parseCookies, setCookie } from "../../lib/cookies";
|
||||
import { useEffect } from "react";
|
||||
import { setLoggedInUserId } from "../../store/accountDetails/action";
|
||||
import {
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from "../../actions/services/searchService";
|
||||
|
||||
import GoogleMapReact from "google-map-react";
|
||||
import { parseCookies } from "nookies";
|
||||
import { parseCookies } from "../../lib/cookies";
|
||||
import OSPoint from "ospoint";
|
||||
import {
|
||||
createWatchedCases,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
setCurrentReference
|
||||
} from "../../store/currentView/action";
|
||||
|
||||
import { parseCookies, setCookie } from "nookies";
|
||||
import { parseCookies, setCookie } from "../../lib/cookies";
|
||||
import { useEffect } from "react";
|
||||
import { setLoggedInUserId } from "../../store/accountDetails/action";
|
||||
import {
|
||||
@@ -40,7 +40,6 @@ import resolveCrmDisplayValue from "../../lib/i18n/crmDisplay/resolveCrmDisplayV
|
||||
import { sendGAEvent } from "@next/third-parties/google";
|
||||
import RepsOnResults from "./repsonresults";
|
||||
import LiveLink from "./liveLink";
|
||||
import { query } from "jsonpath";
|
||||
import { splitWatchedCasesBySubmissionState } from "../../lib/domain/dashboard-policy/splitWatchedCasesBySubmissionState";
|
||||
|
||||
const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
|
||||
@@ -687,6 +687,8 @@ export const updateLinks = (input) => {
|
||||
const EMPTY_QUILL_PARAGRAPHS_REGEX =
|
||||
/<p[^>]*>\s*(?:<br\s*\/?>| |\s)*\s*<\/p>/gi;
|
||||
|
||||
const VIDEO_EMBED_REGEX = /<(iframe|video)\b[^>]*>[\s\S]*?<\/\1\s*>/gi;
|
||||
|
||||
const URL_REGEX = /\b(https?:\/\/[^\s<]+)/gi;
|
||||
|
||||
const stripTrailingUrlPunctuation = (url) => {
|
||||
@@ -732,7 +734,9 @@ export const updateLinks = (input) => {
|
||||
const processHtmlString = (htmlString) => {
|
||||
if (typeof htmlString !== "string" || !htmlString) return htmlString;
|
||||
|
||||
let html = htmlString.replace(EMPTY_QUILL_PARAGRAPHS_REGEX, "");
|
||||
let html = htmlString
|
||||
.replace(VIDEO_EMBED_REGEX, "")
|
||||
.replace(EMPTY_QUILL_PARAGRAPHS_REGEX, "");
|
||||
|
||||
const anchorPlaceholders = [];
|
||||
html = html.replace(/<a\b[^>]*>[\s\S]*?<\/a>/gi, (match) => {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
||||
const DNSForm = (props) => {
|
||||
const { caseReference } = props;
|
||||
|
||||
return <></>;
|
||||
};
|
||||
|
||||
export default DNSForm;
|
||||
@@ -1,353 +0,0 @@
|
||||
const ElectricityActForm = (props) => {
|
||||
const { caseReference } = props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-grid-column-two-thirds">
|
||||
<h1 class="govuk-heading-m govuk-!-margin-top-5">
|
||||
Enter your appeal information
|
||||
</h1>
|
||||
<form>
|
||||
<div class="govuk-grid-column-full">
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_name"
|
||||
>
|
||||
Name
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="pinswg_name"
|
||||
id="pinswg_name"
|
||||
component="[object Object]"
|
||||
class="govuk-input govuk-input--width-20"
|
||||
disabled
|
||||
value="CAS-00497-K4H2Z5"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_anticipatedgridreferencenorthingtext"
|
||||
id="pinswg_anticipatedgridreferencenorthingtext_label"
|
||||
>
|
||||
Anticipated grid reference northing
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_anticipatedgridreferencenorthingtext"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_anticipatedgridreferenceeastingtext"
|
||||
id="pinswg_anticipatedgridreferenceeastingtext_label"
|
||||
>
|
||||
Anticipated grid reference easting
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_anticipatedgridreferenceeastingtext"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_projectname"
|
||||
id="pinswg_projectname_label"
|
||||
>
|
||||
Project name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_projectname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_projectdiscription"
|
||||
id="pinswg_projectdiscription_label"
|
||||
>
|
||||
Project description
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_projectdiscription"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_projectlocation"
|
||||
id="pinswg_projectlocation_label"
|
||||
>
|
||||
Project location
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_projectlocation"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addresscounty"
|
||||
id="pinswg_addresscounty_label"
|
||||
>
|
||||
Address county
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addresscounty"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addressline1"
|
||||
id="pinswg_addressline1_label"
|
||||
>
|
||||
Address line 1
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addressline1"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addressline2"
|
||||
id="pinswg_addressline2_label"
|
||||
>
|
||||
Address line 2
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addressline2"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addresstown"
|
||||
id="pinswg_addresstown_label"
|
||||
>
|
||||
Address Town
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addresstown"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_postcode"
|
||||
id="pinswg_postcode_label"
|
||||
>
|
||||
Post Code
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_postcode"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_agentcontactname"
|
||||
id="pinswg_agentcontactname_label"
|
||||
>
|
||||
Agent contact name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_agentcontactname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_emailaddress"
|
||||
id="pinswg_emailaddress_label"
|
||||
>
|
||||
Email Address
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_emailaddress"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_salutation"
|
||||
id="pinswg_salutation_label"
|
||||
>
|
||||
Salutation
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_salutation"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_firstname"
|
||||
id="pinswg_firstname_label"
|
||||
>
|
||||
First Name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_firstname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_lastname"
|
||||
id="pinswg_lastname_label"
|
||||
>
|
||||
Last Name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_lastname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_organisation"
|
||||
id="pinswg_organisation_label"
|
||||
>
|
||||
Organisation
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_organisation"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_role"
|
||||
id="pinswg_role_label"
|
||||
>
|
||||
Role
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_role"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_telephonenumber"
|
||||
id="pinswg_telephonenumber_label"
|
||||
>
|
||||
Telephone Number
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_telephonenumber"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_webaddress"
|
||||
id="pinswg_webaddress_label"
|
||||
>
|
||||
Web Address
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_webaddress"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-button-group">
|
||||
<button
|
||||
type="submit"
|
||||
class="govuk-button"
|
||||
data-module="govuk-button"
|
||||
>
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ElectricityActForm;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,353 +0,0 @@
|
||||
const HarbourRevisionOrderForm = (props) => {
|
||||
const { caseReference } = props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-grid-column-two-thirds">
|
||||
<h1 class="govuk-heading-m govuk-!-margin-top-5">
|
||||
Enter your appeal information
|
||||
</h1>
|
||||
<form>
|
||||
<div class="govuk-grid-column-full">
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_name"
|
||||
>
|
||||
Name
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="pinswg_name"
|
||||
id="pinswg_name"
|
||||
component="[object Object]"
|
||||
class="govuk-input govuk-input--width-20"
|
||||
disabled
|
||||
value="CAS-00499-C4D7R4"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_anticipatedgridreferenceeastingtext"
|
||||
id="pinswg_anticipatedgridreferenceeastingtext_label"
|
||||
>
|
||||
Anticipated grid reference easting
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_anticipatedgridreferenceeastingtext"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_anticipatedgridreferencenorthingtext"
|
||||
id="pinswg_anticipatedgridreferencenorthingtext_label"
|
||||
>
|
||||
Anticipated grid reference northing
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_anticipatedgridreferencenorthingtext"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_projectname"
|
||||
id="pinswg_projectname_label"
|
||||
>
|
||||
Project name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_projectname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_projectdiscription"
|
||||
id="pinswg_projectdiscription_label"
|
||||
>
|
||||
Project description
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_projectdiscription"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_projectlocation"
|
||||
id="pinswg_projectlocation_label"
|
||||
>
|
||||
Project location
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_projectlocation"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addresscounty"
|
||||
id="pinswg_addresscounty_label"
|
||||
>
|
||||
Address county
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addresscounty"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addressline1"
|
||||
id="pinswg_addressline1_label"
|
||||
>
|
||||
Address line 1
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addressline1"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addressline2"
|
||||
id="pinswg_addressline2_label"
|
||||
>
|
||||
Address line 2
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addressline2"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addresstown"
|
||||
id="pinswg_addresstown_label"
|
||||
>
|
||||
Address Town
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addresstown"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_agentcontactname"
|
||||
id="pinswg_agentcontactname_label"
|
||||
>
|
||||
Agent contact name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_agentcontactname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_emailaddress"
|
||||
id="pinswg_emailaddress_label"
|
||||
>
|
||||
Email Address
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_emailaddress"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_salutation"
|
||||
id="pinswg_salutation_label"
|
||||
>
|
||||
Salutation
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_salutation"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_firstname"
|
||||
id="pinswg_firstname_label"
|
||||
>
|
||||
First Name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_firstname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_lastname"
|
||||
id="pinswg_lastname_label"
|
||||
>
|
||||
Last Name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_lastname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_organisation"
|
||||
id="pinswg_organisation_label"
|
||||
>
|
||||
Organisation
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_organisation"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_postcode"
|
||||
id="pinswg_postcode_label"
|
||||
>
|
||||
Post Code
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_postcode"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_role"
|
||||
id="pinswg_role_label"
|
||||
>
|
||||
Role
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_role"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_telephonenumber"
|
||||
id="pinswg_telephonenumber_label"
|
||||
>
|
||||
Telephone Number
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_telephonenumber"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_webaddress"
|
||||
id="pinswg_webaddress_label"
|
||||
>
|
||||
Web Address
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_webaddress"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-button-group">
|
||||
<button
|
||||
type="submit"
|
||||
class="govuk-button"
|
||||
data-module="govuk-button"
|
||||
>
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default HarbourRevisionOrderForm;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,49 +0,0 @@
|
||||
const LdpForm = (props) => {
|
||||
const { caseReference } = props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-grid-column-two-thirds">
|
||||
<h1 class="govuk-heading-m govuk-!-margin-top-5">
|
||||
Enter your appeal information
|
||||
</h1>
|
||||
<form>
|
||||
<div class="govuk-grid-column-full">
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_name"
|
||||
>
|
||||
Name
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="pinswg_name"
|
||||
id="pinswg_name"
|
||||
component="[object Object]"
|
||||
class="govuk-input govuk-input--width-20"
|
||||
disabled
|
||||
value="CAS-00508-J6L1F0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-button-group">
|
||||
<button
|
||||
type="submit"
|
||||
class="govuk-button"
|
||||
data-module="govuk-button"
|
||||
>
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default LdpForm;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
-1918
File diff suppressed because it is too large
Load Diff
@@ -1,353 +0,0 @@
|
||||
const TransportAndWorkActForm = (props) => {
|
||||
const { caseReference } = props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-grid-column-two-thirds">
|
||||
<h1 class="govuk-heading-m govuk-!-margin-top-5">
|
||||
Enter your appeal information
|
||||
</h1>
|
||||
<form>
|
||||
<div class="govuk-grid-column-full">
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_name"
|
||||
>
|
||||
Name
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="pinswg_name"
|
||||
id="pinswg_name"
|
||||
component="[object Object]"
|
||||
class="govuk-input govuk-input--width-20"
|
||||
disabled
|
||||
value="CAS-00498-H2F6B6"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_anticipatedgridreferenceeastingtext"
|
||||
id="pinswg_anticipatedgridreferenceeastingtext_label"
|
||||
>
|
||||
Anticipated grid reference easting
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_anticipatedgridreferenceeastingtext"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_anticipatedgridreferencenorthingtext"
|
||||
id="pinswg_anticipatedgridreferencenorthingtext_label"
|
||||
>
|
||||
Anticipated grid reference northing
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_anticipatedgridreferencenorthingtext"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_projectname"
|
||||
id="pinswg_projectname_label"
|
||||
>
|
||||
Project name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_projectname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_projectlocation"
|
||||
id="pinswg_projectlocation_label"
|
||||
>
|
||||
Project location
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_projectlocation"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_projectdescription"
|
||||
id="pinswg_projectdescription_label"
|
||||
>
|
||||
Project Description
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_projectdescription"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addresscounty"
|
||||
id="pinswg_addresscounty_label"
|
||||
>
|
||||
Address county
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addresscounty"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addressline1"
|
||||
id="pinswg_addressline1_label"
|
||||
>
|
||||
Address line 1
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addressline1"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addressline2"
|
||||
id="pinswg_addressline2_label"
|
||||
>
|
||||
Address line 2
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addressline2"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_addresstown"
|
||||
id="pinswg_addresstown_label"
|
||||
>
|
||||
Address Town
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_addresstown"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_agentcontactname"
|
||||
id="pinswg_agentcontactname_label"
|
||||
>
|
||||
Agent contact name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_agentcontactname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_emailaddress"
|
||||
id="pinswg_emailaddress_label"
|
||||
>
|
||||
Email Address
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_emailaddress"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_salutation"
|
||||
id="pinswg_salutation_label"
|
||||
>
|
||||
Salutation
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_salutation"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_firstname"
|
||||
id="pinswg_firstname_label"
|
||||
>
|
||||
First Name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_firstname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_lastname"
|
||||
id="pinswg_lastname_label"
|
||||
>
|
||||
Last Name
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_lastname"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_organisation"
|
||||
id="pinswg_organisation_label"
|
||||
>
|
||||
Organisation
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_organisation"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_postcode"
|
||||
id="pinswg_postcode_label"
|
||||
>
|
||||
Post Code
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_postcode"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_role"
|
||||
id="pinswg_role_label"
|
||||
>
|
||||
Role
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_role"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_telephonenumber"
|
||||
id="pinswg_telephonenumber_label"
|
||||
>
|
||||
Telephone Number
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_telephonenumber"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-form-group ">
|
||||
<label
|
||||
class="govuk-label "
|
||||
for="pinswg_webaddress"
|
||||
id="pinswg_webaddress_label"
|
||||
>
|
||||
Web Address
|
||||
</label>
|
||||
<input
|
||||
class="govuk-input govuk-input--width-20"
|
||||
id="pinswg_webaddress"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="govuk-button-group">
|
||||
<button
|
||||
type="submit"
|
||||
class="govuk-button"
|
||||
data-module="govuk-button"
|
||||
>
|
||||
Submit
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default TransportAndWorkActForm;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,143 @@
|
||||
# Administrative authentication foundation
|
||||
|
||||
## Integrated administrative sign-in
|
||||
|
||||
Administrators sign in at `/admin/login` using the shared credential configured
|
||||
as `ADMIN_AUTH_SECRET`. The page submits the credential directly to
|
||||
`POST /api/admin/auth/login`; it does not place the credential in a URL or store
|
||||
it in browser storage.
|
||||
|
||||
Successful authentication creates the administrative session cookie and sends
|
||||
the browser to `/admin`. The `/admin` server-side loader validates that cookie
|
||||
before loading administrative data. A valid session is not sufficient by
|
||||
itself: the existing `/admin` IP allowlist remains an additional restriction,
|
||||
and a valid administrator outside the allowed network is sent to `/403`.
|
||||
|
||||
The administrative interface provides a **Sign out** control which calls
|
||||
`POST /api/admin/auth/logout`, clears the cookie, and returns the browser to
|
||||
`/admin/login`. Sessions expire after 20 minutes and expired, invalid, or
|
||||
missing sessions are redirected to the login page.
|
||||
|
||||
## Required server-side configuration
|
||||
|
||||
The deployment must provide all of the following server-side values:
|
||||
|
||||
- `ADMIN_AUTH_SECRET`: a unique high-entropy administrative passphrase of at
|
||||
least 32 characters.
|
||||
- `ADMIN_SESSION_SECRET`: a different unique high-entropy signing key of at
|
||||
least 32 characters.
|
||||
- `NEXTAUTH_URL`: the existing canonical application URL. Administrative login
|
||||
and logout compare the request `Origin` with this server-configured origin.
|
||||
|
||||
The administrative values must never use a `NEXT_PUBLIC_` prefix or be exposed
|
||||
to browser JavaScript. Do not commit real values. Missing, short, or identical
|
||||
administrative secrets fail closed.
|
||||
|
||||
## Security properties and limitations
|
||||
|
||||
- Credentials are derived with Node `scrypt` and compared with
|
||||
`timingSafeEqual`.
|
||||
- Sessions are stateless, versioned HMAC-SHA256 tokens with a 20-minute fixed
|
||||
lifetime and a random nonce.
|
||||
- The cookie is `HttpOnly`, `SameSite=Strict`, scoped to `/`, explicitly
|
||||
expires, and is `Secure` in production.
|
||||
- Login and logout require an exact same-origin `Origin` match against
|
||||
`NEXTAUTH_URL`; missing or malformed origins fail closed.
|
||||
- Authentication responses use `Cache-Control: no-store`.
|
||||
- Logout clears the browser cookie. Because sessions are stateless, a stolen
|
||||
token can remain valid until its short expiry; later protected routes must
|
||||
continue verifying signature and expiry on every request.
|
||||
- This is shared-credential authentication. A valid token proves knowledge of
|
||||
the shared credential, not the identity of a named administrator.
|
||||
- Protecting `/admin` prevents its server-side Prisma, storage, and CRM data
|
||||
loading from running without a valid administrative session. It does not by
|
||||
itself protect browser-addressable API routes.
|
||||
|
||||
## Administrative API protection limitations
|
||||
|
||||
The current administrative UI directly uses API routes that do not yet enforce
|
||||
the administrative session, including:
|
||||
|
||||
- `/api/admin/getnewappeals_api`
|
||||
- `/api/admin/getlatestdocuments_api`
|
||||
- `/api/admin/getStatusCountsByAppeal_api`
|
||||
- `/api/admin/getStatusCountsByAppealAndLPA_api`
|
||||
|
||||
The appeals and documents routes expose paging operations used after the page
|
||||
has loaded. The status routes expose administrative dashboard reads. These
|
||||
routes retain their existing relay token and HMAC behaviour but have no
|
||||
independent administrative-session authorization. A later authorised stage
|
||||
must enforce the administrative session on privileged API routes and account
|
||||
for both browser calls and the existing server-side bootstrap callers.
|
||||
|
||||
Storage download and queue actions retain their existing authorization
|
||||
behaviour. The other administrative API and storage limitations described in
|
||||
this section remain open.
|
||||
|
||||
Directly observed storage routes include:
|
||||
|
||||
- `/api/file/getrepsblobproxy`, which forwards a caller-supplied container using
|
||||
server relay credentials and path signing.
|
||||
- `/api/file/downloadblob` and `/api/file/createrepcompletemessage_api`, which
|
||||
enforce existing path-HMAC checks but not administrative authorization.
|
||||
|
||||
## Stage 3 deletion controls
|
||||
|
||||
Ordinary case and representation deletion through `/api/file/deleteblobcase`
|
||||
and `/api/file/deleteblobrep` now requires a valid NextAuth session whose user
|
||||
ID matches the requested Azure container. The existing signed-query/HMAC check
|
||||
also remains required. Requests that fail ownership or HMAC validation are
|
||||
rejected before the Azure storage deletion operation is called.
|
||||
|
||||
Ordinary JSON and multipart uploads through `/api/file/upload` and
|
||||
`/api/file/uploadsinglefile` independently require a valid NextAuth session whose
|
||||
user ID exactly matches the submitted `containerID`. The existing upload HMAC
|
||||
remains mandatory. Missing or unusable sessions, cross-container requests, and
|
||||
invalid HMACs are rejected before file processing or Azure storage writes.
|
||||
|
||||
Administrative cross-container representation deletion uses the dedicated
|
||||
`POST /api/admin/deleteblobrep` route. That endpoint independently validates
|
||||
the administrative session and requires a trusted same-origin request. It also
|
||||
validates the requested container, case-folder segment, and representation-file
|
||||
segment before performing deletion.
|
||||
|
||||
Administrative cross-container case deletion uses the dedicated
|
||||
`POST /api/admin/deleteblobcase` route. That endpoint independently validates
|
||||
the administrative session, requires a trusted same-origin request, and
|
||||
validates the requested container and case-folder segment before performing
|
||||
deletion. It invokes the same existing `deleteBlobCase(container,
|
||||
casefolderID)` operation as the ordinary endpoint. That operation lists and
|
||||
deletes blobs in the selected container whose names begin with the supplied
|
||||
case-folder prefix; it does not delete the Azure container or broaden deletion
|
||||
to unrelated containers.
|
||||
|
||||
Administrative representation JSON unlocking uses the dedicated
|
||||
`POST /api/admin/editRepJson` route. That endpoint independently validates the
|
||||
administrative session, requires a trusted same-origin request, and validates
|
||||
the requested container and blob path before removing `repComplete`. The former
|
||||
`/api/file/editRepJson` route is retired and no longer performs storage access.
|
||||
|
||||
Automated contract verification for the implemented deletion controls has
|
||||
passed, including ordinary ownership/HMAC rejection, administrative method,
|
||||
session, origin and input rejection, zero deletion calls on rejected requests,
|
||||
and exact cross-container helper arguments on success. Live Azure behaviour,
|
||||
browser-level behaviour, and deployment configuration have not been verified
|
||||
by that automated coverage. The other administrative API and storage
|
||||
limitations documented above remain open, and these changes do not establish
|
||||
closure of the overall ITHC finding.
|
||||
|
||||
## Deployment requirements before production use
|
||||
|
||||
The repository does not provide a demonstrated distributed rate-limit service.
|
||||
Administrative login must therefore be protected by an ingress, gateway, WAF,
|
||||
or shared backing service that enforces rate limits consistently across all
|
||||
deployed instances. A process-local limiter is intentionally not used because
|
||||
it would reset on restart and could be bypassed across instances.
|
||||
|
||||
The deployment must also ensure `NEXTAUTH_URL` is the correct canonical HTTPS
|
||||
origin. Login and logout intentionally do not derive trust from `Host` or
|
||||
forwarding headers.
|
||||
|
||||
Any future administrative state-changing API must require more than possession
|
||||
of the cookie: it must independently validate the administrative session and
|
||||
enforce same-origin/CSRF protection before performing side effects.
|
||||
@@ -0,0 +1,25 @@
|
||||
import { defineConfig } from "eslint/config";
|
||||
import nextVitals from "eslint-config-next/core-web-vitals";
|
||||
import reactPlugin from "eslint-plugin-react";
|
||||
|
||||
export default defineConfig([
|
||||
...nextVitals,
|
||||
{
|
||||
plugins: {
|
||||
react: reactPlugin
|
||||
},
|
||||
rules: {
|
||||
"@next/next/no-img-element": "off",
|
||||
"react/no-unknown-property": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ["pages/api/file/**/*.js"],
|
||||
rules: {
|
||||
"react-hooks/rules-of-hooks": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
ignores: [".next/**", "out/**", "build/**", "next-env.d.ts"]
|
||||
}
|
||||
]);
|
||||
@@ -88,9 +88,9 @@ module.exports = {
|
||||
"/details-about-cookies": ["common", "cookies"],
|
||||
"/terms-and-conditions": ["common"],
|
||||
"/account/passwordreset": ["common", "home"],
|
||||
"/auth/signin": ["common", "common", "auth"],
|
||||
"/auth/verify-request": ["common", "common", "auth"],
|
||||
"/auth/error": ["common", "common", "auth"],
|
||||
"/auth/signin": ["common", "account", "auth"],
|
||||
"/auth/verify-request": ["common", "account", "auth"],
|
||||
"/auth/error": ["common", "account", "auth"],
|
||||
"/admin": ["case"]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
import {
|
||||
createHash,
|
||||
createHmac,
|
||||
randomBytes,
|
||||
scryptSync,
|
||||
timingSafeEqual
|
||||
} from "crypto";
|
||||
|
||||
export const ADMIN_SESSION_COOKIE = "pedw_admin_session";
|
||||
export const ADMIN_SESSION_TTL_SECONDS = 20 * 60;
|
||||
export const ADMIN_PASSPHRASE_MAX_LENGTH = 512;
|
||||
|
||||
const TOKEN_VERSION = "v1";
|
||||
const AUTH_DERIVATION_SALT = "pedw-admin-auth-v1";
|
||||
const MINIMUM_SECRET_LENGTH = 32;
|
||||
const CLOCK_SKEW_SECONDS = 60;
|
||||
|
||||
const isValidSecret = (value) =>
|
||||
typeof value === "string" && value.length >= MINIMUM_SECRET_LENGTH;
|
||||
|
||||
const getAdminConfiguration = (env = process.env) => {
|
||||
const authSecret = env.ADMIN_AUTH_SECRET;
|
||||
const sessionSecret = env.ADMIN_SESSION_SECRET;
|
||||
|
||||
if (!isValidSecret(authSecret) || !isValidSecret(sessionSecret)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const authDigest = createHash("sha256").update(authSecret).digest();
|
||||
const sessionDigest = createHash("sha256").update(sessionSecret).digest();
|
||||
|
||||
if (timingSafeEqual(authDigest, sessionDigest)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return { authSecret, sessionSecret };
|
||||
};
|
||||
|
||||
const deriveCredential = (value) =>
|
||||
scryptSync(value, AUTH_DERIVATION_SALT, 32, {
|
||||
N: 16384,
|
||||
r: 8,
|
||||
p: 1,
|
||||
maxmem: 32 * 1024 * 1024
|
||||
});
|
||||
|
||||
const encode = (value) => Buffer.from(value).toString("base64url");
|
||||
|
||||
const decode = (value) => Buffer.from(value, "base64url");
|
||||
|
||||
export const validateAdminPassphrase = (
|
||||
passphrase,
|
||||
{ env = process.env } = {}
|
||||
) => {
|
||||
const configuration = getAdminConfiguration(env);
|
||||
|
||||
if (
|
||||
!configuration ||
|
||||
typeof passphrase !== "string" ||
|
||||
passphrase.length === 0 ||
|
||||
passphrase.length > ADMIN_PASSPHRASE_MAX_LENGTH
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const expected = deriveCredential(configuration.authSecret);
|
||||
const supplied = deriveCredential(passphrase);
|
||||
|
||||
return timingSafeEqual(expected, supplied);
|
||||
};
|
||||
|
||||
export const issueAdminSession = (
|
||||
{ env = process.env, now = Date.now, nonce = () => randomBytes(16) } = {}
|
||||
) => {
|
||||
const configuration = getAdminConfiguration(env);
|
||||
if (!configuration) return null;
|
||||
|
||||
const issuedAt = Math.floor(now() / 1000);
|
||||
const payload = {
|
||||
v: 1,
|
||||
iat: issuedAt,
|
||||
exp: issuedAt + ADMIN_SESSION_TTL_SECONDS,
|
||||
nonce: nonce().toString("base64url")
|
||||
};
|
||||
const encodedPayload = encode(JSON.stringify(payload));
|
||||
const signature = createHmac("sha256", configuration.sessionSecret)
|
||||
.update(`${TOKEN_VERSION}.${encodedPayload}`)
|
||||
.digest("base64url");
|
||||
|
||||
return `${TOKEN_VERSION}.${encodedPayload}.${signature}`;
|
||||
};
|
||||
|
||||
export const validateAdminSession = (
|
||||
token,
|
||||
{ env = process.env, now = Date.now } = {}
|
||||
) => {
|
||||
const configuration = getAdminConfiguration(env);
|
||||
|
||||
if (!configuration || typeof token !== "string" || token.length > 2048) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const parts = token.split(".");
|
||||
if (parts.length !== 3 || parts[0] !== TOKEN_VERSION) return false;
|
||||
|
||||
const [version, encodedPayload, suppliedSignature] = parts;
|
||||
const base64UrlPattern = /^[A-Za-z0-9_-]+$/;
|
||||
if (
|
||||
!base64UrlPattern.test(encodedPayload) ||
|
||||
!base64UrlPattern.test(suppliedSignature)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const expectedSignature = createHmac("sha256", configuration.sessionSecret)
|
||||
.update(`${version}.${encodedPayload}`)
|
||||
.digest();
|
||||
|
||||
let suppliedSignatureBuffer;
|
||||
try {
|
||||
suppliedSignatureBuffer = decode(suppliedSignature);
|
||||
} catch (_error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
suppliedSignatureBuffer.length !== expectedSignature.length ||
|
||||
!timingSafeEqual(expectedSignature, suppliedSignatureBuffer)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let payload;
|
||||
try {
|
||||
payload = JSON.parse(decode(encodedPayload).toString("utf8"));
|
||||
} catch (_error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const currentTime = Math.floor(now() / 1000);
|
||||
|
||||
return (
|
||||
payload?.v === 1 &&
|
||||
Number.isInteger(payload.iat) &&
|
||||
Number.isInteger(payload.exp) &&
|
||||
typeof payload.nonce === "string" &&
|
||||
payload.nonce.length > 0 &&
|
||||
payload.exp - payload.iat === ADMIN_SESSION_TTL_SECONDS &&
|
||||
payload.iat <= currentTime + CLOCK_SKEW_SECONDS &&
|
||||
payload.exp > currentTime
|
||||
);
|
||||
};
|
||||
|
||||
const cookieSecurityAttributes = (production) => [
|
||||
"Path=/",
|
||||
"HttpOnly",
|
||||
"SameSite=Strict",
|
||||
...(production ? ["Secure"] : [])
|
||||
];
|
||||
|
||||
export const createAdminSessionCookie = (
|
||||
token,
|
||||
{ now = Date.now, production = process.env.NODE_ENV === "production" } = {}
|
||||
) => {
|
||||
const expires = new Date(now() + ADMIN_SESSION_TTL_SECONDS * 1000);
|
||||
|
||||
return [
|
||||
`${ADMIN_SESSION_COOKIE}=${encodeURIComponent(token)}`,
|
||||
`Max-Age=${ADMIN_SESSION_TTL_SECONDS}`,
|
||||
`Expires=${expires.toUTCString()}`,
|
||||
...cookieSecurityAttributes(production)
|
||||
].join("; ");
|
||||
};
|
||||
|
||||
export const createClearedAdminSessionCookie = (
|
||||
{ production = process.env.NODE_ENV === "production" } = {}
|
||||
) =>
|
||||
[
|
||||
`${ADMIN_SESSION_COOKIE}=`,
|
||||
"Max-Age=0",
|
||||
"Expires=Thu, 01 Jan 1970 00:00:00 GMT",
|
||||
...cookieSecurityAttributes(production)
|
||||
].join("; ");
|
||||
|
||||
export const readAdminSessionCookie = (req) => {
|
||||
const rawCookie = req?.headers?.cookie;
|
||||
if (typeof rawCookie !== "string") return null;
|
||||
|
||||
for (const entry of rawCookie.split(";")) {
|
||||
const separator = entry.indexOf("=");
|
||||
if (separator === -1) continue;
|
||||
|
||||
const name = entry.slice(0, separator).trim();
|
||||
if (name !== ADMIN_SESSION_COOKIE) continue;
|
||||
|
||||
try {
|
||||
return decodeURIComponent(entry.slice(separator + 1).trim());
|
||||
} catch (_error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const hasTrustedSameOrigin = (req, { env = process.env } = {}) => {
|
||||
const requestOrigin = req?.headers?.origin;
|
||||
const configuredUrl = env.NEXTAUTH_URL;
|
||||
|
||||
if (
|
||||
typeof requestOrigin !== "string" ||
|
||||
typeof configuredUrl !== "string" ||
|
||||
configuredUrl.length === 0
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return new URL(requestOrigin).origin === new URL(configuredUrl).origin;
|
||||
} catch (_error) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const setAdminAuthNoStore = (res) => {
|
||||
res.setHeader("Cache-Control", "no-store, max-age=0");
|
||||
res.setHeader("Pragma", "no-cache");
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* NextAuth email provider configuration for PEDW.
|
||||
*
|
||||
* PEDW supplies its own sendVerificationRequest implementation using
|
||||
* GOV.UK Notify, so the default Nodemailer SMTP sender is unnecessary.
|
||||
*
|
||||
* Preserve the NextAuth v4 email provider configuration contract.
|
||||
*/
|
||||
const EmailProvider = (options = {}) => ({
|
||||
id: "email",
|
||||
type: "email",
|
||||
name: "Email",
|
||||
server: {
|
||||
host: "localhost",
|
||||
port: 25,
|
||||
auth: {
|
||||
user: "",
|
||||
pass: ""
|
||||
}
|
||||
},
|
||||
from: "NextAuth <no-reply@example.com>",
|
||||
maxAge: 24 * 60 * 60,
|
||||
async sendVerificationRequest() {
|
||||
throw new Error(
|
||||
"PEDW requires a custom GOV.UK Notify verification sender"
|
||||
);
|
||||
},
|
||||
options
|
||||
});
|
||||
|
||||
export default EmailProvider;
|
||||
@@ -1,4 +1,4 @@
|
||||
import { destroyCookie } from "nookies";
|
||||
import { destroyCookie } from "../cookies";
|
||||
import { signOut } from "next-auth/react";
|
||||
|
||||
const AUTH_COOKIE_CANDIDATES = [
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
import * as cookie from "cookie";
|
||||
import setCookieParser from "set-cookie-parser";
|
||||
|
||||
const isBrowser = () => typeof window !== "undefined";
|
||||
|
||||
const createCookie = (name, value, options) => {
|
||||
let sameSite = options.sameSite;
|
||||
|
||||
if (sameSite === true) {
|
||||
sameSite = "strict";
|
||||
}
|
||||
|
||||
if (sameSite === undefined || sameSite === false) {
|
||||
sameSite = "lax";
|
||||
}
|
||||
|
||||
const cookieToSet = { ...options, sameSite };
|
||||
delete cookieToSet.encode;
|
||||
|
||||
return { name, value, ...cookieToSet };
|
||||
};
|
||||
|
||||
const hasSameProperties = (firstCookie, secondCookie) => {
|
||||
const firstProperties = Object.getOwnPropertyNames(firstCookie);
|
||||
const secondProperties = Object.getOwnPropertyNames(secondCookie);
|
||||
|
||||
if (firstProperties.length !== secondProperties.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return firstProperties.every(
|
||||
(propertyName) =>
|
||||
firstCookie[propertyName] === secondCookie[propertyName]
|
||||
);
|
||||
};
|
||||
|
||||
const areCookiesEqual = (firstCookie, secondCookie) => {
|
||||
let sameSiteMatches = firstCookie.sameSite === secondCookie.sameSite;
|
||||
|
||||
if (
|
||||
typeof firstCookie.sameSite === "string" &&
|
||||
typeof secondCookie.sameSite === "string"
|
||||
) {
|
||||
sameSiteMatches =
|
||||
firstCookie.sameSite.toLowerCase() ===
|
||||
secondCookie.sameSite.toLowerCase();
|
||||
}
|
||||
|
||||
return (
|
||||
hasSameProperties(
|
||||
{ ...firstCookie, sameSite: undefined },
|
||||
{ ...secondCookie, sameSite: undefined }
|
||||
) && sameSiteMatches
|
||||
);
|
||||
};
|
||||
|
||||
export const parseCookies = (ctx, options) => {
|
||||
if (ctx?.req?.headers?.cookie) {
|
||||
return cookie.parse(ctx.req.headers.cookie, options);
|
||||
}
|
||||
|
||||
if (isBrowser()) {
|
||||
return cookie.parse(document.cookie, options);
|
||||
}
|
||||
|
||||
return {};
|
||||
};
|
||||
|
||||
export const setCookie = (ctx, name, value, options = {}) => {
|
||||
if (ctx?.res?.getHeader && ctx.res.setHeader) {
|
||||
if (ctx?.res?.finished) {
|
||||
console.warn(`Not setting "${name}" cookie. Response has finished.`);
|
||||
console.warn("You should set cookie before res.send()");
|
||||
return {};
|
||||
}
|
||||
|
||||
let cookies = ctx.res.getHeader("Set-Cookie") || [];
|
||||
|
||||
if (typeof cookies === "string") {
|
||||
cookies = [cookies];
|
||||
}
|
||||
|
||||
if (typeof cookies === "number") {
|
||||
cookies = [];
|
||||
}
|
||||
|
||||
const parsedCookies = setCookieParser.parse(cookies, {
|
||||
decodeValues: false
|
||||
});
|
||||
const newCookie = createCookie(name, value, options);
|
||||
const cookiesToSet = [];
|
||||
|
||||
parsedCookies.forEach((parsedCookie) => {
|
||||
if (!areCookiesEqual(parsedCookie, newCookie)) {
|
||||
cookiesToSet.push(
|
||||
cookie.serialize(parsedCookie.name, parsedCookie.value, {
|
||||
encode: (cookieValue) => cookieValue,
|
||||
...parsedCookie
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
cookiesToSet.push(cookie.serialize(name, value, options));
|
||||
ctx.res.setHeader("Set-Cookie", cookiesToSet);
|
||||
}
|
||||
|
||||
if (isBrowser()) {
|
||||
if (options?.httpOnly) {
|
||||
throw new Error("Can not set a httpOnly cookie in the browser.");
|
||||
}
|
||||
|
||||
document.cookie = cookie.serialize(name, value, options);
|
||||
}
|
||||
|
||||
return {};
|
||||
};
|
||||
|
||||
export const destroyCookie = (ctx, name, options) =>
|
||||
setCookie(ctx, name, "", { ...(options || {}), maxAge: -1 });
|
||||
@@ -120,7 +120,9 @@ export const loadRepresentationBootstrap = async ({ ctx }) => {
|
||||
|
||||
const [accountDetails, myRepresentations] = await Promise.all([
|
||||
getPersonalAccount(loggedInUser),
|
||||
getRepsFromBlob(thisSession.user.id)
|
||||
getRepsFromBlob(thisSession.user.id, {
|
||||
headers: { Cookie: ctx.req?.headers?.cookie || "" }
|
||||
})
|
||||
]);
|
||||
|
||||
const myRepresentationsDetails = await getDetails(
|
||||
|
||||
@@ -472,15 +472,6 @@ export const createDetailAndAccountRouteRenderers = ({
|
||||
{t("account:account-title")}
|
||||
</li>
|
||||
</>
|
||||
),
|
||||
|
||||
"/account/changepassword": () => (
|
||||
<>
|
||||
{renderLinkCrumb(cyMyPortalHref, t("common:breadcrumb-my-portal"))}
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
Update your password
|
||||
</li>
|
||||
</>
|
||||
)
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
const LINK_REMOVED = "[web link removed]";
|
||||
const OBFUSCATING_SPACE = "[\\s\\u0000-\\u001f\\u007f\\u200b-\\u200d\\ufeff]*";
|
||||
const SCHEME = `h${OBFUSCATING_SPACE}t${OBFUSCATING_SPACE}t${OBFUSCATING_SPACE}p(?:${OBFUSCATING_SPACE}s)?${OBFUSCATING_SPACE}:${OBFUSCATING_SPACE}\\/${OBFUSCATING_SPACE}\\/`;
|
||||
const DOMAIN = "(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}";
|
||||
const URL_TAIL = "[^\\s<>\\\"']*";
|
||||
|
||||
const explicitUrlPattern = () => new RegExp(`${SCHEME}${DOMAIN}${URL_TAIL}`, "gi");
|
||||
const wwwUrlPattern = () => new RegExp(`\\bwww\\.${DOMAIN}${URL_TAIL}`, "gi");
|
||||
const bareDomainWithPathPattern = () =>
|
||||
new RegExp(`(^|[^a-z0-9@._-])(${DOMAIN}\\/[^\\s<>\\\"']*)`, "gi");
|
||||
|
||||
const stripTrailingPunctuation = (value) => {
|
||||
let destination = value;
|
||||
let punctuation = "";
|
||||
|
||||
while (/[.,!;:]$/.test(destination)) {
|
||||
punctuation = destination.slice(-1) + punctuation;
|
||||
destination = destination.slice(0, -1);
|
||||
}
|
||||
|
||||
while (/[)\]}]$/.test(destination)) {
|
||||
punctuation = destination.slice(-1) + punctuation;
|
||||
destination = destination.slice(0, -1);
|
||||
}
|
||||
|
||||
return { destination, punctuation };
|
||||
};
|
||||
|
||||
const replaceUrlMatch = (value) => {
|
||||
const { destination, punctuation } = stripTrailingPunctuation(value);
|
||||
return destination ? LINK_REMOVED + punctuation : value;
|
||||
};
|
||||
|
||||
const containsWebDestination = (value) => {
|
||||
explicitUrlPattern().lastIndex = 0;
|
||||
wwwUrlPattern().lastIndex = 0;
|
||||
bareDomainWithPathPattern().lastIndex = 0;
|
||||
|
||||
return (
|
||||
explicitUrlPattern().test(value) ||
|
||||
wwwUrlPattern().test(value) ||
|
||||
bareDomainWithPathPattern().test(value)
|
||||
);
|
||||
};
|
||||
|
||||
export default function removeContactUsEmailLinks(message) {
|
||||
if (typeof message !== "string") {
|
||||
return message;
|
||||
}
|
||||
|
||||
let transformed = message;
|
||||
|
||||
transformed = transformed.replace(
|
||||
/<a\b[^>]*>([\s\S]*?)<\/a\s*>/gi,
|
||||
(match, linkText) =>
|
||||
containsWebDestination(match)
|
||||
? `${linkText}${linkText ? " " : ""}${LINK_REMOVED}`
|
||||
: match
|
||||
);
|
||||
|
||||
transformed = transformed.replace(/<[^>]+>/gi, (tag) =>
|
||||
containsWebDestination(tag) ? LINK_REMOVED : tag
|
||||
);
|
||||
|
||||
transformed = transformed.replace(
|
||||
/\[([^\]]*)\]\(([^)]*)\)/gi,
|
||||
(match, linkText, destination) =>
|
||||
containsWebDestination(destination)
|
||||
? `${linkText}${linkText ? " " : ""}${LINK_REMOVED}`
|
||||
: match
|
||||
);
|
||||
|
||||
transformed = transformed.replace(explicitUrlPattern(), replaceUrlMatch);
|
||||
transformed = transformed.replace(wwwUrlPattern(), replaceUrlMatch);
|
||||
transformed = transformed.replace(
|
||||
bareDomainWithPathPattern(),
|
||||
(match, prefix, destination) => prefix + replaceUrlMatch(destination)
|
||||
);
|
||||
|
||||
return transformed;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { relayGetData } from "../../pages/api/middleware/relayForwarding";
|
||||
import { RELAY_POLICY_LOOKUP } from "../../pages/api/middleware/relayPolicyPresets";
|
||||
|
||||
export const getCrmPersonalAccount = async (contactId) => {
|
||||
const queryUrl =
|
||||
"contacts(" +
|
||||
contactId +
|
||||
")?$select=firstname, lastname, emailaddress1, telephone1, pinswg_companyname, address1_line1,address1_line2,address1_city, address1_county,address1_postalcode,pinswg_typeofinvolvement,pinswg_contact_associatedlpa,pinswg_preferredlanguage&$count=true";
|
||||
|
||||
const { data } = await relayGetData({
|
||||
queryUrl,
|
||||
relayPolicy: RELAY_POLICY_LOOKUP
|
||||
});
|
||||
|
||||
return data;
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import axios from "axios";
|
||||
import { getToken } from "../../actions/core/token";
|
||||
import { hashAPIPath } from "../../actions/core/hash";
|
||||
|
||||
const WEBAPI_URL =
|
||||
process.env.RELAY_ROOT ||
|
||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
||||
|
||||
export const updateCrmContact = async (contactId, updatePayload) => {
|
||||
const token = await getToken();
|
||||
const queryUrl = "contacts(" + contactId + ")";
|
||||
|
||||
const config = {
|
||||
method: "patch",
|
||||
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
Accept: "application/json",
|
||||
Prefer: 'odata.include-annotations="*",return=representation',
|
||||
Authorization: "Bearer " + token.access_token,
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
data: JSON.stringify(updatePayload)
|
||||
};
|
||||
|
||||
const response = await axios(config);
|
||||
return response.data;
|
||||
};
|
||||
@@ -17,6 +17,10 @@
|
||||
"summary-case-stage-label": "Cam yr Achos",
|
||||
"summary-environmental-statement-label": "Lleoliad Datganiad Amgylcheddol",
|
||||
"summary-last-modified-label": "Addaswyd ddiwethaf",
|
||||
"summary-make-consultation-response-para-a": "Gellir cyflwyno ymatebion i ymgynghoriadau, neu sylwadau, ar gyfer yr achos hwn bellach. I gael rhagor o wybodaeth am gyflwyno sylwadau i PCAC, gweler ein ",
|
||||
"summary-make-representation-para-a": "Gellir cyflwyno sylwadau, neu gynrychioliadau, ar gyfer yr achos hwn bellach. I gael rhagor o wybodaeth am gyflwyno sylwadau i PCAC, gweler ein ",
|
||||
"summary-make-representation-para-a-link": "https://www.llyw.cymru/defnyddio-deallusrwydd-artiffisial-ai-mewn-cyflwyniadau-i-pcac",
|
||||
"summary-make-representation-para-a-label": "Canllawiau ar ddefnyddio Deallusrwydd Artiffisial Cynhyrchiol",
|
||||
"summary-make-representation-label": "Cyflwyno sylwadau",
|
||||
"summary-make-consultation-label": "Cyflwyno Ymateb i'r Ymgynghoriad",
|
||||
"summary-representation-open-label": "Cynrychioliadau yn agor",
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
"cancel-link": "Canslo",
|
||||
"save-exit-button": "Cadw a gadael",
|
||||
"submit-and-start": "Cyflwyno a dechrau'r cwrs",
|
||||
"footer-pedw-use-ai-label": "Sut mae PCAC yn defnyddio deallusrwydd artiffisial (AI)",
|
||||
"footer-pedw-use-ai-link": "https://www.llyw.cymru/penderfyniadau-cynllunio-ac-amgylchedd-cymru/sut-mae-pcac-yn-defnyddio-deallusrwydd-artiffisial-ai",
|
||||
"footer-terms-conditions-link-label": "Telerau ac amodau",
|
||||
"footer-terms-conditions-link": "https://llyw.cymru/gwaith-achos-cynllunio-telerau-ac-amodau",
|
||||
"footer-privacy-link-label": "Preifatrwydd",
|
||||
@@ -30,9 +32,9 @@
|
||||
"footer-accessibility-link": "/hygyrchedd",
|
||||
"footer-feedback-link": "Rhowch adborth i ni ar y dudalen hon",
|
||||
"footer-contact-us-link-label": "Cysylltu â ni",
|
||||
"footer-contact-us-link": "https://www.llyw.cymru/penderfyniadau-cynllunio-ac-amgylchedd-cymru/datganiad-hawlfraint",
|
||||
"footer-contact-us-link": "https://llyw.cymru/penderfyndiadau-cynllunio-ac-amgylchedd-cymru/cysylltwch-ni",
|
||||
"footer-copyright-link-label": "Datganiad hawlfraint",
|
||||
"footer-copyright-link": "https://llyw.cymru/datganiad-hawlfraint",
|
||||
"footer-copyright-link": "https://www.llyw.cymru/penderfyniadau-cynllunio-ac-amgylchedd-cymru/datganiad-hawlfraint",
|
||||
"footer-alternative-languages-link-label": "Ieithoedd amgen",
|
||||
"footer-alternative-languages-link": "https://llyw.cymru/ieithoedd-amgen",
|
||||
"footer-guidance-link-label": "Canllawiau a gwasanaethau Penderfyniadau Cynllunio ac Amgylchedd Cymru",
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
"ai-policy-notice-paragraph-one": "Deellir y gall partïon ddewis defnyddio Deallusrwydd Artiffisial Cynhyrchiol (AI) wrth gyflwyno apeliadau neu gynrychioliadau i PCAC. Er bod gan y rhai sy'n ymgysylltu â PCAC hawl i ddefnyddio AI i gynorthwyo eu cyflwyniadau, dylid nodi y gall cynnwys a gynhyrchir gan AI gynnwys honiadau ffug neu ddi-sail.",
|
||||
"ai-policy-notice-paragraph-two": "Gan y bydd cyflwyniadau ysgrifenedig yn destun craffu yn y broses apelio – ac o bosibl yn destun croesholi mewn gwrandawiadau ac ymchwiliadau – ni ddylech wneud cyflwyniadau ysgrifenedig nad ydych yn eu deall neu nad ydych yn gwybod eu bod yn gywir. Gall cyflwyno tystiolaeth anghywir arwain at gostau diangen wrth wirio neu wrthbrofi'r dystiolaeth honno, a gallai arwain at orchymyn i chi dalu costau. Gweler ein ",
|
||||
"ai-policy-notice-paragraph-two-a-label": "Canllawiau ar ddefnyddio Deallusrwydd Artiffisial (AI) Cynhyrchiol",
|
||||
"ai-policy-notice-paragraph-two-a-link": "https://www.gov.wales/using-ai-submissions-pedw",
|
||||
"ai-policy-notice-paragraph-two-a-link": "https://www.llyw.cymru/defnyddio-deallusrwydd-artiffisial-ai-mewn-cyflwyniadau-i-pcac",
|
||||
"ai-policy-notice-paragraph-two-b": " am ragor o wybodaeth.",
|
||||
"ai-policy-notice-dismiss-button": "Rwy'n deall",
|
||||
"contact-us-heading": "Cysylltu â ni",
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
"summary-case-stage-label": "Case Stage",
|
||||
"summary-environmental-statement-label": "Environmental Statement Location",
|
||||
"summary-last-modified-label": "Last modified",
|
||||
"summary-make-consultation-response-para-a": "Consultations responses, or comments, may now be submitted for this case. For further information on making submissions to PEDW, please see our ",
|
||||
"summary-make-representation-para-a": "Representations, or comments, may now be submitted for this case. For further information on making submissions to PEDW, please see our ",
|
||||
"summary-make-representation-para-a-link": "https://www.gov.wales/using-ai-submissions-pedw",
|
||||
"summary-make-representation-para-a-label": "Guidance for the use of Generative AI",
|
||||
"summary-make-representation-label": "Make representation",
|
||||
"summary-make-consultation-label": "Submit a Consultation Response",
|
||||
"summary-representation-open-label": "Representations open",
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
"cancel-link": "Cancel",
|
||||
"save-exit-button": "Save and exit",
|
||||
"submit-and-start": "Submit and start course",
|
||||
"footer-pedw-use-ai-label": "How PEDW uses AI",
|
||||
"footer-pedw-use-ai-link": "https://www.gov.wales/planning-and-environment-decisions-wales/how-pedw-uses-ai",
|
||||
"footer-terms-conditions-link-label": "Terms and conditions",
|
||||
"footer-terms-conditions-link": "https://gov.wales/planning-casework-terms-and-conditions",
|
||||
"footer-privacy-link-label": "Privacy",
|
||||
@@ -30,9 +32,9 @@
|
||||
"footer-accessibility-link": "/accessibility",
|
||||
"footer-feedback-link": "Give feedback about this page",
|
||||
"footer-contact-us-link-label": "Contact us",
|
||||
"footer-contact-us-link": "https://www.gov.wales/planning-and-environment-decisions-wales/copyright-statement",
|
||||
"footer-contact-us-link": "https://www.gov.wales/planning-and-environment-decisions-wales/contact-us",
|
||||
"footer-copyright-link-label": "Copyright statement",
|
||||
"footer-copyright-link": "https://gov.wales/copyright-statement",
|
||||
"footer-copyright-link": "https://www.gov.wales/planning-and-environment-decisions-wales/copyright-statement",
|
||||
"footer-alternative-languages-link-label": "Alternative languages",
|
||||
"footer-alternative-languages-link": "https://gov.wales/alternative-languages",
|
||||
"footer-guidance-link-label": "Planning and Environment Decisions Wales’ guidance and services",
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ export function middleware(request) {
|
||||
);
|
||||
|
||||
// XSS protection (legacy)
|
||||
response.headers.set("X-XSS-Protection", "1; mode=block");
|
||||
response.headers.set("X-XSS-Protection", "0");
|
||||
|
||||
// Prevent MIME type sniffing
|
||||
response.headers.set("X-Content-Type-Options", "nosniff");
|
||||
|
||||
Vendored
+3
-1
@@ -1,5 +1,7 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
import "./.next/types/routes.d.ts";
|
||||
import "./.next/types/root-params.d.ts";
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
|
||||
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
|
||||
|
||||
+32
-7
@@ -46,29 +46,30 @@ const securityHeaders = [
|
||||
},
|
||||
{
|
||||
key: "X-XSS-Protection",
|
||||
value: "1; mode=block"
|
||||
value: "0"
|
||||
}
|
||||
// {
|
||||
// key: "Content-Security-Policy",
|
||||
// value: "frame-src 'self'; child-src 'self';object-src 'none'; script-src 'self' 'https://www.googletagmanager.com' unsafe-inline",
|
||||
// },
|
||||
];
|
||||
const noStoreHeaders = [
|
||||
{
|
||||
key: "Cache-Control",
|
||||
value: "no-store"
|
||||
}
|
||||
];
|
||||
//const buildId = nextBuildId.sync({ dir: __dirname });
|
||||
const buildId = Date.now().toString();
|
||||
|
||||
module.exports = {
|
||||
//output: "standalone",
|
||||
eslint: {
|
||||
// Warning: This allows production builds to successfully complete even if
|
||||
// your project has ESLint errors.
|
||||
ignoreDuringBuilds: true
|
||||
},
|
||||
reactStrictMode: false,
|
||||
env: {
|
||||
BUILD_ID_ENV: buildId
|
||||
},
|
||||
swcMinify: false,
|
||||
sassOptions: {
|
||||
quietDeps: true,
|
||||
includePaths: [
|
||||
"/styles/sass",
|
||||
"node_modules/govuk-frontend/govuk/all",
|
||||
@@ -82,6 +83,30 @@ module.exports = {
|
||||
// Apply these headers to all routes in your application.
|
||||
source: "/(.*)?",
|
||||
headers: securityHeaders
|
||||
},
|
||||
{
|
||||
source:
|
||||
"/api/:family(admin|email|file|myportal|subscriptions)/:path*",
|
||||
headers: noStoreHeaders
|
||||
},
|
||||
{
|
||||
source: "/api/auth/resolve-locale",
|
||||
headers: noStoreHeaders
|
||||
},
|
||||
{
|
||||
source:
|
||||
"/api/endpoint/:route(createaccount_api|getaccounts_api|getemailaccountcheck_api|getpersonalaccount_api|getportallogin_api|getportalloginproxy_api|getpreferredlanguage_api|updateaccount_api|gethash_api|createcrmtask_api)",
|
||||
headers: noStoreHeaders
|
||||
},
|
||||
{
|
||||
source:
|
||||
"/api/endpoint/:route(getmycases_api|getmylpacases_api|getmyrepresentations_api|getmyrepresentationsproxy_api|getawaitingsubmission_api|getawaitingsubmissionproxy_api|getwatchedcases_api|getwatchedcasesproxy_api|createwatchedcases_api|deletewatchedcases_api|deletewatchedcasesproxy_api|deleteawaitingsubmissions_api)",
|
||||
headers: noStoreHeaders
|
||||
},
|
||||
{
|
||||
source:
|
||||
"/api/endpoint/:route(getbasicpartsaveddetails_api|getpartsavedappeal_api|getappealid_api|getappealpdfdocuments_api|getportalmoduledetails_api|getportalmoduledetailsproxy_api|patchcase_api|updatecase_api)",
|
||||
headers: noStoreHeaders
|
||||
}
|
||||
];
|
||||
},
|
||||
|
||||
Generated
+2740
-4095
File diff suppressed because it is too large
Load Diff
+25
-27
@@ -2,15 +2,23 @@
|
||||
"name": "acp",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"overrides": {
|
||||
"webpack": {
|
||||
"terser-webpack-plugin": {
|
||||
".": "5.3.17",
|
||||
"schema-utils": "4.3.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"dev": "next dev --webpack",
|
||||
"debugdev": "NODE_OPTIONS='--inspect' next dev",
|
||||
"dev:app": "node ./server/server.js",
|
||||
"build": "NODE_ENV=production node_modules/next/dist/bin/next build",
|
||||
"build": "NODE_ENV=production node_modules/next/dist/bin/next build --webpack",
|
||||
"start2": "NODE_ENV=production node ./server.js",
|
||||
"start3": "NODE_ENV=production next start",
|
||||
"start": "NODE_ENV=production node_modules/next/dist/bin/next start",
|
||||
"lint": "next lint",
|
||||
"lint": "eslint .",
|
||||
"prisma:generate": "prisma generate",
|
||||
"test": "playwright test",
|
||||
"test:reps": "playwright test pwe2e/tests/loggedin/raiserep.spec.js --headed",
|
||||
@@ -22,49 +30,42 @@
|
||||
"child_process": false
|
||||
},
|
||||
"dependencies": {
|
||||
"@auth/prisma-adapter": "^1.0.10",
|
||||
"@azure/identity": "^4.0.0",
|
||||
"@azure/identity": "4.14.1",
|
||||
"@azure/storage-blob": "^12.17.0",
|
||||
"@azure/storage-queue": "^12.16.0",
|
||||
"@microsoft/applicationinsights-react-js": "^17.3.2",
|
||||
"@microsoft/applicationinsights-web": "^3.3.2",
|
||||
"@next-auth/prisma-adapter": "^1.0.7",
|
||||
"@next/third-parties": "latest",
|
||||
"@next/third-parties": "16.4.4",
|
||||
"@prisma/client": "^5.7.0",
|
||||
"@react-pdf/renderer": "^3.1.14",
|
||||
"@redux-devtools/extension": "^3.3.0",
|
||||
"@xmldom/xmldom": "^0.8.10",
|
||||
"applicationinsights": "^2.9.1",
|
||||
"axios": "^1.7.7",
|
||||
"compression": "^1.7.4",
|
||||
"axios": "^1.21.0",
|
||||
"cookie": "0.7.2",
|
||||
"cookie-cutter": "^0.2.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"date-fns": "^2.30.0",
|
||||
"dom": "^0.0.3",
|
||||
"express": "^4.18.2",
|
||||
"file-type": "^20.4.1",
|
||||
"express": "^4.22.3",
|
||||
"file-type": "22.3.0",
|
||||
"fs": "0.0.2",
|
||||
"google-map-react": "^2.2.1",
|
||||
"govuk-frontend": "^5.0.0",
|
||||
"history": "^5.3.0",
|
||||
"jsonpath": "^1.1.1",
|
||||
"jsonpath-plus": "^10.3.0",
|
||||
"leaflet": "^1.9.4",
|
||||
"leaflet-defaulticon-compatibility": "^0.1.2",
|
||||
"lodash": "^4.17.21",
|
||||
"moment": "^2.29.4",
|
||||
"multiparty": "^4.2.3",
|
||||
"mysql": "^2.18.1",
|
||||
"next": "^14.2.28",
|
||||
"next-auth": "^4.24.4",
|
||||
"next": "16.4.4",
|
||||
"next-auth": "4.24.15",
|
||||
"next-build-id": "^3.0.0",
|
||||
"next-connect": "^0.12.2",
|
||||
"next-redux-wrapper": "^7.0.5",
|
||||
"next-swagger-doc": "^0.4.0",
|
||||
"next-translate": "^2.6.2",
|
||||
"next-translate-plugin": "^2.6.2",
|
||||
"nodemailer": "^6.9.7",
|
||||
"nookies": "^2.5.2",
|
||||
"notifications-node-client": "^7.0.6",
|
||||
"openapi-types": "^12.1.3",
|
||||
"ospoint": "^0.2.1",
|
||||
@@ -75,15 +76,13 @@
|
||||
"react": "^18.2.0",
|
||||
"react-accessible-accordion": "^5.0.0",
|
||||
"react-autosuggest": "^10.1.0",
|
||||
"react-cookie-consent": "^9.0.0",
|
||||
"react-cookie-consent": "^10.0.2",
|
||||
"react-datepicker": "4.24.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-dropzone": "^14.2.3",
|
||||
"react-idle-timer": "^5.7.2",
|
||||
"react-leaflet": "^4.2.1",
|
||||
"react-pdf": "^7.6.0",
|
||||
"react-pdf-html": "^1.1.18",
|
||||
"react-quill": "^2.0.0",
|
||||
"react-quill-new": "^3.3.3",
|
||||
"react-redux": "^7.2.6",
|
||||
"redux": "^4.2.1",
|
||||
@@ -92,12 +91,11 @@
|
||||
"redux-thunk": "^2.4.2",
|
||||
"sass": "1.69",
|
||||
"sass-loader": "13.3.2",
|
||||
"swagger-ui": "^5.18.2",
|
||||
"swagger-ui-react": "^5.18.2",
|
||||
"set-cookie-parser": "2.7.0",
|
||||
"tslib": "^2.7.0",
|
||||
"typescript": "^5.3.2",
|
||||
"uuid": "9.0.0",
|
||||
"webpack": "^5.66.0",
|
||||
"uuid": "11.1.1",
|
||||
"webpack": "5.112.2",
|
||||
"xpath": "^0.0.32"
|
||||
},
|
||||
"resolutions": {
|
||||
@@ -106,8 +104,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.62.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-next": "^14.2.28",
|
||||
"eslint": "9.39.5",
|
||||
"eslint-config-next": "16.4.4",
|
||||
"eslint-plugin-jsdoc": "^48.2.3",
|
||||
"prisma": "^5.0.0"
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import Document, { Html, Head, Main, NextScript } from "next/document";
|
||||
import SkipLink from "../components/skiplink";
|
||||
import { Tracking, TrackingNoScript } from "../components/tracking";
|
||||
//import { nanoid } from "nanoid";
|
||||
import { setCookie } from "nookies";
|
||||
import { setCookie } from "../lib/cookies";
|
||||
import Script from "next/script";
|
||||
|
||||
class MyDocument extends Document {
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import Link from "next/link";
|
||||
import CookieBanner from "../components/cookieBanner";
|
||||
import Footer from "../components/footer";
|
||||
import Header from "../components/header";
|
||||
import { parseCookies, setCookie, destroyCookie } from "nookies";
|
||||
import { parseCookies, setCookie, destroyCookie } from "../lib/cookies";
|
||||
import { useSession, signIn, signOut } from "next-auth/react";
|
||||
|
||||
function Error({ statusCode }, props) {
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
import Link from "next/link";
|
||||
import _ from "lodash";
|
||||
import Head from "next/head";
|
||||
import Header from "../../components/header";
|
||||
import Banner from "../../components/banner";
|
||||
import CookieBanner from "../../components/cookieBanner";
|
||||
import Breadcrumbs from "../../components/breadcrumbs";
|
||||
import Footer from "../../components/footer";
|
||||
|
||||
import { useSelector, shallowEqual, connect } from "react-redux";
|
||||
import { wrapper } from "../../store/store";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
import { useState } from "react";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import { JSONPath as jsonpath } from "jsonpath-plus";
|
||||
import { reduxForm, formValueSelector } from "redux-form";
|
||||
|
||||
import ChangePassword from "../../components/account/changepassword";
|
||||
import xpath from "xpath";
|
||||
import {
|
||||
setAppealType,
|
||||
setAppealTypeTitle,
|
||||
setAppealTypeID,
|
||||
setAppealLPA,
|
||||
getAppealTypeObj
|
||||
} from "../../store/appealType/action";
|
||||
import {
|
||||
getAppealsTypes,
|
||||
getLPA
|
||||
} from "../../actions/services/referenceDataService";
|
||||
import { setLPA } from "../../store/lpa/action";
|
||||
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
import NoSessionWarning from "../../components/nosession";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages, formData } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { appealtypes } = router.query;
|
||||
|
||||
const { appealType, LPAData } = props;
|
||||
const [passwordUpdated, setPasswordUpdated] = useState(false);
|
||||
|
||||
const { data: session, status } = useSession();
|
||||
|
||||
if (status === "loading") {
|
||||
return <NoSessionWarning loading={true} />;
|
||||
}
|
||||
|
||||
if (status === "unauthenticated") {
|
||||
router.push("/auth/signin");
|
||||
return <NoSessionWarning />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>
|
||||
{t("search:page-title")} - {t("common:service-name")}
|
||||
</title>
|
||||
</Head>
|
||||
<div id="page_wrapper">
|
||||
<CookieBanner />
|
||||
<Header />
|
||||
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<div className="govuk-width-container">
|
||||
<Breadcrumbs slug={appealtypes} props={props} />
|
||||
<main
|
||||
className="govuk-main-wrapper--auto-spacing"
|
||||
id="main-content"
|
||||
role="main"
|
||||
>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-two-thirds">
|
||||
{passwordUpdated == true ? (
|
||||
<h1>
|
||||
Your password has been changed
|
||||
</h1>
|
||||
) : (
|
||||
<h1>Change password</h1>
|
||||
)}
|
||||
<ChangePassword
|
||||
props={props}
|
||||
setPasswordUpdated={
|
||||
setPasswordUpdated
|
||||
}
|
||||
passwordUpdated={passwordUpdated}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Footer footerLinks={footerLinks} ticketnumber={props} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
search: state.search,
|
||||
searchResultsObj: state.searchResultsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
LPAData: state.LPAData,
|
||||
form: state.form,
|
||||
accountDetails: state.accountDetails
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(Home);
|
||||
@@ -20,7 +20,7 @@ import { reduxForm, formValueSelector } from "redux-form";
|
||||
import PersonalDetails from "../../components/account/personaldetails";
|
||||
import { setAccountDetails } from "../../store/accountDetails/action";
|
||||
import { getPersonalAccount } from "../../actions/services/accountService";
|
||||
import { setCookie } from "nookies";
|
||||
import { setCookie } from "../../lib/cookies";
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
import NoSessionWarning from "../../components/nosession";
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// pages/admin/storage.js
|
||||
import { useState } from "react";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import CookieBanner from "../../components/cookieBanner";
|
||||
import Header from "../../components/header";
|
||||
import Footer from "../../components/footer";
|
||||
@@ -29,6 +30,10 @@ import {
|
||||
setSearchResults
|
||||
} from "../../store/searchOutput/action";
|
||||
import { setCurrentPage } from "../../store/currentView/action";
|
||||
import {
|
||||
readAdminSessionCookie,
|
||||
validateAdminSession
|
||||
} from "../../lib/admin/adminAuth";
|
||||
|
||||
const StoragePage = (props) => {
|
||||
const {
|
||||
@@ -42,6 +47,27 @@ const StoragePage = (props) => {
|
||||
statusLPAObj
|
||||
} = props;
|
||||
const [whichTab, setWhichTab] = useState("appealDashboard");
|
||||
const [signingOut, setSigningOut] = useState(false);
|
||||
const router = useRouter();
|
||||
|
||||
const handleSignOut = async () => {
|
||||
setSigningOut(true);
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/admin/auth/logout", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
credentials: "same-origin"
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
await router.replace("/admin/login");
|
||||
return;
|
||||
}
|
||||
} finally {
|
||||
setSigningOut(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -57,6 +83,16 @@ const StoragePage = (props) => {
|
||||
style={{ width: "90%", margin: "auto" }}
|
||||
>
|
||||
<div className="js-enabled govuk-template__body govuk-frontend-supported">
|
||||
<div className="govuk-!-margin-top-4 govuk-!-text-align-right">
|
||||
<button
|
||||
type="button"
|
||||
className="govuk-button govuk-button--secondary"
|
||||
onClick={handleSignOut}
|
||||
disabled={signingOut}
|
||||
>
|
||||
{signingOut ? "Signing out..." : "Sign out"}
|
||||
</button>
|
||||
</div>
|
||||
<div className="govuk-tabs" data-module="govuk-tabs">
|
||||
<h2 className="govuk-tabs__title">Contents</h2>
|
||||
|
||||
@@ -199,6 +235,14 @@ const StoragePage = (props) => {
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
const adminSession = readAdminSessionCookie(req);
|
||||
|
||||
if (!validateAdminSession(adminSession)) {
|
||||
return {
|
||||
redirect: { destination: "/admin/login", permanent: false }
|
||||
};
|
||||
}
|
||||
|
||||
// IP restriction check
|
||||
const ALLOWED_IPS = process.env.ALLOWED_IPS
|
||||
? process.env.ALLOWED_IPS.split(",").map((ip) => ip.trim())
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { useState } from "react";
|
||||
import CookieBanner from "../../components/cookieBanner";
|
||||
import Footer from "../../components/footer";
|
||||
import Header from "../../components/header";
|
||||
import {
|
||||
readAdminSessionCookie,
|
||||
validateAdminSession
|
||||
} from "../../lib/admin/adminAuth";
|
||||
|
||||
const AdminLoginPage = () => {
|
||||
const router = useRouter();
|
||||
const [passphrase, setPassphrase] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
const handleSubmit = async (event) => {
|
||||
event.preventDefault();
|
||||
setError("");
|
||||
setSubmitting(true);
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/admin/auth/login", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
credentials: "same-origin",
|
||||
body: JSON.stringify({ passphrase })
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
setError("Sign in failed. Check the details and try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
await router.replace("/admin");
|
||||
} catch (_error) {
|
||||
setError("Sign in failed. Check the details and try again.");
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>Administrative sign in</title>
|
||||
</Head>
|
||||
<div id="page_wrapper">
|
||||
<CookieBanner />
|
||||
<Header />
|
||||
<main
|
||||
className="govuk-width-container govuk-main-wrapper govuk-!-padding-bottom-9"
|
||||
id="main-content"
|
||||
>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-two-thirds">
|
||||
<h1 className="govuk-heading-l">
|
||||
Administrative sign in
|
||||
</h1>
|
||||
|
||||
{error && (
|
||||
<div
|
||||
className="govuk-error-summary"
|
||||
role="alert"
|
||||
aria-labelledby="admin-login-error-title"
|
||||
tabIndex={-1}
|
||||
>
|
||||
<h2
|
||||
className="govuk-error-summary__title"
|
||||
id="admin-login-error-title"
|
||||
>
|
||||
There is a problem
|
||||
</h2>
|
||||
<div className="govuk-error-summary__body">
|
||||
<p>{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<div
|
||||
className={`govuk-form-group${
|
||||
error ? " govuk-form-group--error" : ""
|
||||
}`}
|
||||
>
|
||||
<label
|
||||
className="govuk-label govuk-label--m"
|
||||
htmlFor="admin-passphrase"
|
||||
>
|
||||
Password
|
||||
</label>
|
||||
{error && (
|
||||
<p
|
||||
id="admin-passphrase-error"
|
||||
className="govuk-error-message"
|
||||
>
|
||||
<span className="govuk-visually-hidden">
|
||||
Error:
|
||||
</span>{" "}
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
<input
|
||||
className={`govuk-input${
|
||||
error ? " govuk-input--error" : ""
|
||||
}`}
|
||||
id="admin-passphrase"
|
||||
name="passphrase"
|
||||
type="password"
|
||||
autoComplete="current-password"
|
||||
value={passphrase}
|
||||
onChange={(event) =>
|
||||
setPassphrase(event.target.value)
|
||||
}
|
||||
aria-describedby={
|
||||
error
|
||||
? "admin-passphrase-error"
|
||||
: undefined
|
||||
}
|
||||
aria-invalid={error ? "true" : undefined}
|
||||
disabled={submitting}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
className="govuk-button"
|
||||
type="submit"
|
||||
disabled={submitting}
|
||||
>
|
||||
{submitting ? "Signing in..." : "Sign in"}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps = async ({ req }) => {
|
||||
const adminSession = readAdminSessionCookie(req);
|
||||
|
||||
if (validateAdminSession(adminSession)) {
|
||||
return {
|
||||
redirect: { destination: "/admin", permanent: false }
|
||||
};
|
||||
}
|
||||
|
||||
return { props: {} };
|
||||
};
|
||||
|
||||
export default AdminLoginPage;
|
||||
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
createAdminSessionCookie,
|
||||
hasTrustedSameOrigin,
|
||||
issueAdminSession,
|
||||
setAdminAuthNoStore,
|
||||
validateAdminPassphrase
|
||||
} from "../../../../lib/admin/adminAuth";
|
||||
import { respondError, respondSuccess } from "../../middleware/apiResponse";
|
||||
|
||||
const forbidden = (res) =>
|
||||
respondError(res, {
|
||||
status: 403,
|
||||
code: "FORBIDDEN",
|
||||
message: "Request not permitted"
|
||||
});
|
||||
|
||||
export default async function handler(req, res) {
|
||||
setAdminAuthNoStore(res);
|
||||
res.setHeader("Allow", "POST");
|
||||
|
||||
if (req.method !== "POST") {
|
||||
return respondError(res, {
|
||||
status: 405,
|
||||
code: "METHOD_NOT_ALLOWED",
|
||||
message: "Method not allowed"
|
||||
});
|
||||
}
|
||||
|
||||
if (!hasTrustedSameOrigin(req)) return forbidden(res);
|
||||
|
||||
const passphrase = req.body?.passphrase;
|
||||
if (!validateAdminPassphrase(passphrase)) return forbidden(res);
|
||||
|
||||
const token = issueAdminSession();
|
||||
if (!token) return forbidden(res);
|
||||
|
||||
res.setHeader("Set-Cookie", createAdminSessionCookie(token));
|
||||
return respondSuccess(res, { authenticated: true });
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import {
|
||||
createClearedAdminSessionCookie,
|
||||
hasTrustedSameOrigin,
|
||||
setAdminAuthNoStore
|
||||
} from "../../../../lib/admin/adminAuth";
|
||||
import { respondError, respondSuccess } from "../../middleware/apiResponse";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
setAdminAuthNoStore(res);
|
||||
res.setHeader("Allow", "POST");
|
||||
|
||||
if (req.method !== "POST") {
|
||||
return respondError(res, {
|
||||
status: 405,
|
||||
code: "METHOD_NOT_ALLOWED",
|
||||
message: "Method not allowed"
|
||||
});
|
||||
}
|
||||
|
||||
if (!hasTrustedSameOrigin(req)) {
|
||||
return respondError(res, {
|
||||
status: 403,
|
||||
code: "FORBIDDEN",
|
||||
message: "Request not permitted"
|
||||
});
|
||||
}
|
||||
|
||||
res.setHeader("Set-Cookie", createClearedAdminSessionCookie());
|
||||
return respondSuccess(res, { authenticated: false });
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
readAdminSessionCookie,
|
||||
setAdminAuthNoStore,
|
||||
validateAdminSession
|
||||
} from "../../../../lib/admin/adminAuth";
|
||||
import { respondError, respondSuccess } from "../../middleware/apiResponse";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
setAdminAuthNoStore(res);
|
||||
res.setHeader("Allow", "GET");
|
||||
|
||||
if (req.method !== "GET") {
|
||||
return respondError(res, {
|
||||
status: 405,
|
||||
code: "METHOD_NOT_ALLOWED",
|
||||
message: "Method not allowed"
|
||||
});
|
||||
}
|
||||
|
||||
const token = readAdminSessionCookie(req);
|
||||
return respondSuccess(res, {
|
||||
authenticated: validateAdminSession(token)
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import { createRepCompleteMessage } from "../../../actions/azurestorage";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import {
|
||||
hasTrustedSameOrigin,
|
||||
readAdminSessionCookie,
|
||||
setAdminAuthNoStore,
|
||||
validateAdminSession
|
||||
} from "../../../lib/admin/adminAuth";
|
||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
||||
|
||||
const forbidden = (res) =>
|
||||
respondError(res, {
|
||||
status: 403,
|
||||
code: "FORBIDDEN",
|
||||
message: "Request not permitted"
|
||||
});
|
||||
|
||||
const isValidContainer = (value) =>
|
||||
typeof value === "string" &&
|
||||
value.length >= 3 &&
|
||||
value.length <= 63 &&
|
||||
/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(value);
|
||||
|
||||
const isValidPathSegment = (value) =>
|
||||
typeof value === "string" &&
|
||||
value.length > 0 &&
|
||||
value.length <= 255 &&
|
||||
value === value.trim() &&
|
||||
value !== "." &&
|
||||
value !== ".." &&
|
||||
!/[\\/\u0000-\u001f\u007f]/.test(value);
|
||||
|
||||
export default async function handler(req, res) {
|
||||
setAdminAuthNoStore(res);
|
||||
res.setHeader("Allow", "POST");
|
||||
|
||||
if (req.method !== "POST") {
|
||||
return respondError(res, {
|
||||
status: 405,
|
||||
code: "METHOD_NOT_ALLOWED",
|
||||
message: "Method not allowed"
|
||||
});
|
||||
}
|
||||
|
||||
const adminSession = readAdminSessionCookie(req);
|
||||
if (!validateAdminSession(adminSession)) {
|
||||
return forbidden(res);
|
||||
}
|
||||
|
||||
if (!hasTrustedSameOrigin(req)) {
|
||||
return forbidden(res);
|
||||
}
|
||||
|
||||
const { container, tempcaseref, repid } = req.body ?? {};
|
||||
if (
|
||||
!isValidContainer(container) ||
|
||||
!isValidPathSegment(tempcaseref) ||
|
||||
!isValidPathSegment(repid)
|
||||
) {
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "INVALID_REQUEST",
|
||||
message: "Invalid request"
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await createRepCompleteMessage(
|
||||
container,
|
||||
tempcaseref,
|
||||
repid
|
||||
);
|
||||
return respondSuccess(res, data);
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "CREATE_REP_COMPLETE_MESSAGE_FAILED",
|
||||
message: "Failed to create representation complete message"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import { deleteBlobCase } from "../../../actions/azurestorage";
|
||||
import {
|
||||
hasTrustedSameOrigin,
|
||||
readAdminSessionCookie,
|
||||
setAdminAuthNoStore,
|
||||
validateAdminSession
|
||||
} from "../../../lib/admin/adminAuth";
|
||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
||||
|
||||
const forbidden = (res) =>
|
||||
respondError(res, {
|
||||
status: 403,
|
||||
code: "FORBIDDEN",
|
||||
message: "Request not permitted"
|
||||
});
|
||||
|
||||
const isValidContainer = (value) =>
|
||||
typeof value === "string" &&
|
||||
value.length >= 3 &&
|
||||
value.length <= 63 &&
|
||||
/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(value);
|
||||
|
||||
const isValidPathSegment = (value) =>
|
||||
typeof value === "string" &&
|
||||
value.length > 0 &&
|
||||
value.length <= 255 &&
|
||||
value === value.trim() &&
|
||||
value !== "." &&
|
||||
value !== ".." &&
|
||||
!/[\\/\u0000-\u001f\u007f]/.test(value);
|
||||
|
||||
export default async function handler(req, res) {
|
||||
setAdminAuthNoStore(res);
|
||||
res.setHeader("Allow", "POST");
|
||||
|
||||
if (req.method !== "POST") {
|
||||
return respondError(res, {
|
||||
status: 405,
|
||||
code: "METHOD_NOT_ALLOWED",
|
||||
message: "Method not allowed"
|
||||
});
|
||||
}
|
||||
|
||||
const adminSession = readAdminSessionCookie(req);
|
||||
if (
|
||||
!validateAdminSession(adminSession) ||
|
||||
!hasTrustedSameOrigin(req)
|
||||
) {
|
||||
return forbidden(res);
|
||||
}
|
||||
|
||||
const { container, casefolderID } = req.body ?? {};
|
||||
if (!isValidContainer(container) || !isValidPathSegment(casefolderID)) {
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "INVALID_REQUEST",
|
||||
message: "Invalid request"
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await deleteBlobCase(container, casefolderID);
|
||||
return respondSuccess(res, { data });
|
||||
} catch (_error) {
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "DELETE_BLOB_CASE_FAILED",
|
||||
message: "Unable to delete blob case"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import { deleteBlobRep } from "../../../actions/azurestorage";
|
||||
import {
|
||||
hasTrustedSameOrigin,
|
||||
readAdminSessionCookie,
|
||||
setAdminAuthNoStore,
|
||||
validateAdminSession
|
||||
} from "../../../lib/admin/adminAuth";
|
||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
||||
|
||||
const forbidden = (res) =>
|
||||
respondError(res, {
|
||||
status: 403,
|
||||
code: "FORBIDDEN",
|
||||
message: "Request not permitted"
|
||||
});
|
||||
|
||||
const isValidContainer = (value) =>
|
||||
typeof value === "string" &&
|
||||
value.length >= 3 &&
|
||||
value.length <= 63 &&
|
||||
/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(value);
|
||||
|
||||
const isValidPathSegment = (value) =>
|
||||
typeof value === "string" &&
|
||||
value.length > 0 &&
|
||||
value.length <= 255 &&
|
||||
value === value.trim() &&
|
||||
value !== "." &&
|
||||
value !== ".." &&
|
||||
!/[\\/\u0000-\u001f\u007f]/.test(value);
|
||||
|
||||
export default async function handler(req, res) {
|
||||
setAdminAuthNoStore(res);
|
||||
res.setHeader("Allow", "POST");
|
||||
|
||||
if (req.method !== "POST") {
|
||||
return respondError(res, {
|
||||
status: 405,
|
||||
code: "METHOD_NOT_ALLOWED",
|
||||
message: "Method not allowed"
|
||||
});
|
||||
}
|
||||
|
||||
const adminSession = readAdminSessionCookie(req);
|
||||
if (
|
||||
!validateAdminSession(adminSession) ||
|
||||
!hasTrustedSameOrigin(req)
|
||||
) {
|
||||
return forbidden(res);
|
||||
}
|
||||
|
||||
const { container, casefolderID, repfile } = req.body ?? {};
|
||||
if (
|
||||
!isValidContainer(container) ||
|
||||
!isValidPathSegment(casefolderID) ||
|
||||
!isValidPathSegment(repfile)
|
||||
) {
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "INVALID_REQUEST",
|
||||
message: "Invalid request"
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await deleteBlobRep(
|
||||
container,
|
||||
`${casefolderID}/${repfile}`
|
||||
);
|
||||
return respondSuccess(res, { data });
|
||||
} catch (_error) {
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "DELETE_BLOB_REP_FAILED",
|
||||
message: "Unable to delete blob representation"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import { BlobServiceClient } from "@azure/storage-blob";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import {
|
||||
hasTrustedSameOrigin,
|
||||
readAdminSessionCookie,
|
||||
setAdminAuthNoStore,
|
||||
validateAdminSession
|
||||
} from "../../../lib/admin/adminAuth";
|
||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
||||
|
||||
const forbidden = (res) =>
|
||||
respondError(res, {
|
||||
status: 403,
|
||||
code: "FORBIDDEN",
|
||||
message: "Request not permitted"
|
||||
});
|
||||
|
||||
const isValidContainer = (value) =>
|
||||
typeof value === "string" &&
|
||||
value.length >= 3 &&
|
||||
value.length <= 63 &&
|
||||
/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(value);
|
||||
|
||||
const isValidBlobName = (value) =>
|
||||
typeof value === "string" &&
|
||||
value.length > 0 &&
|
||||
value.length <= 1024 &&
|
||||
value === value.trim() &&
|
||||
!/[\\\u0000-\u001f\u007f]/.test(value) &&
|
||||
value.split("/").every((segment) => segment && segment !== "." && segment !== "..");
|
||||
|
||||
export default async function handler(req, res) {
|
||||
setAdminAuthNoStore(res);
|
||||
res.setHeader("Allow", "POST");
|
||||
|
||||
if (req.method !== "POST") {
|
||||
return respondError(res, {
|
||||
status: 405,
|
||||
code: "METHOD_NOT_ALLOWED",
|
||||
message: "Method not allowed"
|
||||
});
|
||||
}
|
||||
|
||||
const adminSession = readAdminSessionCookie(req);
|
||||
if (
|
||||
!validateAdminSession(adminSession) ||
|
||||
!hasTrustedSameOrigin(req)
|
||||
) {
|
||||
return forbidden(res);
|
||||
}
|
||||
|
||||
const { container, blobName } = req.body ?? {};
|
||||
if (!isValidContainer(container) || !isValidBlobName(blobName)) {
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "INVALID_REQUEST",
|
||||
message: "Invalid request"
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const accountName = process.env.AZURE_STORAGE_ACCOUNT_NAME;
|
||||
const creds = new DefaultAzureCredential();
|
||||
const blobServiceClient = new BlobServiceClient(
|
||||
`https://${accountName}.blob.core.windows.net`,
|
||||
creds
|
||||
);
|
||||
|
||||
const containerClient = blobServiceClient.getContainerClient(container);
|
||||
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
||||
|
||||
const downloadResponse = await blockBlobClient.download(0);
|
||||
const downloaded = await streamToString(
|
||||
downloadResponse.readableStreamBody
|
||||
);
|
||||
const json = JSON.parse(downloaded);
|
||||
|
||||
if ("repComplete" in json) {
|
||||
delete json.repComplete;
|
||||
}
|
||||
|
||||
const tags = {
|
||||
containerid: json.containerID,
|
||||
caseID: json.ticketnumber,
|
||||
blobType: "Representation"
|
||||
};
|
||||
|
||||
const updatedContent = JSON.stringify(json, null, 2);
|
||||
|
||||
await blockBlobClient.upload(
|
||||
updatedContent,
|
||||
Buffer.byteLength(updatedContent),
|
||||
{
|
||||
blobHTTPHeaders: { blobContentType: "application/json" }
|
||||
}
|
||||
);
|
||||
|
||||
await blockBlobClient.setTags(tags);
|
||||
await blockBlobClient.setMetadata(tags);
|
||||
|
||||
return respondSuccess(res, {
|
||||
message: "repComplete removed successfully"
|
||||
});
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
return respondError(res, {
|
||||
status: 500,
|
||||
code: "EDIT_REP_JSON_FAILED",
|
||||
message: "Failed to edit rep.json"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function streamToString(readableStream) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunks = [];
|
||||
readableStream.on("data", (data) => {
|
||||
chunks.push(data.toString());
|
||||
});
|
||||
readableStream.on("end", () => {
|
||||
resolve(chunks.join(""));
|
||||
});
|
||||
readableStream.on("error", reject);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import { BASE_URL } from "../../../actions/core/env";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
import { azureHeaders } from "../../../actions/core/headers";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import { hashAPIPath } from "../../../actions/core/hash";
|
||||
import axios from "axios";
|
||||
import {
|
||||
ADMIN_SESSION_COOKIE,
|
||||
hasTrustedSameOrigin,
|
||||
readAdminSessionCookie,
|
||||
setAdminAuthNoStore,
|
||||
validateAdminSession
|
||||
} from "../../../lib/admin/adminAuth";
|
||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
||||
|
||||
const isTrustedInternalDestination = () => {
|
||||
try {
|
||||
return (
|
||||
new URL(BASE_URL).origin ===
|
||||
new URL(process.env.NEXTAUTH_URL).origin
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const forbidden = (res) =>
|
||||
respondError(res, {
|
||||
status: 403,
|
||||
code: "FORBIDDEN",
|
||||
message: "Request not permitted"
|
||||
});
|
||||
|
||||
const isValidContainer = (value) =>
|
||||
typeof value === "string" &&
|
||||
value.length >= 3 &&
|
||||
value.length <= 63 &&
|
||||
/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(value);
|
||||
|
||||
export default async function handler(req, res) {
|
||||
setAdminAuthNoStore(res);
|
||||
res.setHeader("Allow", "POST");
|
||||
|
||||
if (req.method !== "POST") {
|
||||
return respondError(res, {
|
||||
status: 405,
|
||||
code: "METHOD_NOT_ALLOWED",
|
||||
message: "Method not allowed"
|
||||
});
|
||||
}
|
||||
|
||||
const adminSession = readAdminSessionCookie(req);
|
||||
if (!validateAdminSession(adminSession) || !hasTrustedSameOrigin(req)) {
|
||||
return forbidden(res);
|
||||
}
|
||||
|
||||
const { container } = req.body ?? {};
|
||||
if (!isValidContainer(container)) {
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "INVALID_REQUEST",
|
||||
message: "Invalid request"
|
||||
});
|
||||
}
|
||||
|
||||
if (!isTrustedInternalDestination()) {
|
||||
return forbidden(res);
|
||||
}
|
||||
|
||||
const token = await getToken();
|
||||
const queryUrl =
|
||||
"/api/file/getrepsblob?container=" + encodeURIComponent(container);
|
||||
|
||||
try {
|
||||
const config = azureHeaders(token.access_token);
|
||||
|
||||
const { data } = await axios.get(
|
||||
BASE_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
{
|
||||
...config,
|
||||
headers: {
|
||||
...config.headers,
|
||||
Cookie: `${ADMIN_SESSION_COOKIE}=${encodeURIComponent(adminSession)}`
|
||||
},
|
||||
maxRedirects: 0
|
||||
}
|
||||
);
|
||||
return respondSuccess(res, data);
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "GET_REPS_BLOB_PROXY_FAILED",
|
||||
message: "Failed to fetch representation blobs"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -13,12 +13,46 @@
|
||||
import { PrismaAdapter } from "@next-auth/prisma-adapter";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import NextAuth from "next-auth";
|
||||
import EmailProvider from "next-auth/providers/email";
|
||||
import EmailProvider from "../../../lib/auth/email-provider";
|
||||
import { consoleLogger, redactSensitive } from "../../../actions/core/logger";
|
||||
import { getPortalLogin } from "../../../actions/services/accountService";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const createVerificationTokenCompletion = () => {
|
||||
let complete;
|
||||
|
||||
const promise = new Promise((resolve) => {
|
||||
complete = resolve;
|
||||
});
|
||||
|
||||
return { promise, complete };
|
||||
};
|
||||
|
||||
const createVerificationTokenSynchronizationAdapter = (
|
||||
verificationTokenCompletion
|
||||
) => {
|
||||
const adapter = PrismaAdapter(prisma);
|
||||
|
||||
return {
|
||||
...adapter,
|
||||
|
||||
async createVerificationToken(data) {
|
||||
try {
|
||||
const result = await adapter.createVerificationToken(data);
|
||||
|
||||
verificationTokenCompletion.complete({ result });
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
verificationTokenCompletion.complete({ error });
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const WELSH_LANGUAGE_CODE = 846040000;
|
||||
|
||||
const authDiagnostic = (event, metadata = {}) => {
|
||||
@@ -165,8 +199,9 @@ const resolveRequestLocale = (req) => {
|
||||
return resolved;
|
||||
};
|
||||
|
||||
const authOptions = (req, res) => {
|
||||
export const authOptions = (req, res) => {
|
||||
const requestLocale = resolveRequestLocale(req);
|
||||
const verificationTokenCompletion = createVerificationTokenCompletion();
|
||||
|
||||
return {
|
||||
providers: [
|
||||
@@ -186,6 +221,13 @@ const authOptions = (req, res) => {
|
||||
effectiveLocale
|
||||
});
|
||||
|
||||
const tokenCreation =
|
||||
await verificationTokenCompletion.promise;
|
||||
|
||||
if (tokenCreation.error) {
|
||||
throw tokenCreation.error;
|
||||
}
|
||||
|
||||
return res
|
||||
.writeHead(200, { "Content-Type": "application/json" })
|
||||
.json({ url: formURL });
|
||||
@@ -240,7 +282,10 @@ const authOptions = (req, res) => {
|
||||
}
|
||||
})
|
||||
],
|
||||
adapter: PrismaAdapter(prisma),
|
||||
|
||||
adapter: createVerificationTokenSynchronizationAdapter(
|
||||
verificationTokenCompletion
|
||||
),
|
||||
secret: process.env.NEXTAUTH_SECRET,
|
||||
session: {
|
||||
strategy: "database",
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import { withSwagger } from 'next-swagger-doc';
|
||||
|
||||
const swaggerHandler = withSwagger({
|
||||
definition: {
|
||||
openapi: '3.0.0',
|
||||
info: {
|
||||
title: 'PEDW Example',
|
||||
version: '0.1.0',
|
||||
},
|
||||
},
|
||||
schemaFolders: ['models'],
|
||||
});
|
||||
export default swaggerHandler();
|
||||
@@ -0,0 +1,246 @@
|
||||
import { isNonEmptyString, sanitizeString } from "../../../actions/core/guards";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import removeContactUsEmailLinks from "../../../lib/security/contactus-email-links";
|
||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
||||
|
||||
const TEMPLATE_IDS = {
|
||||
en: "69228c5f-8500-40ff-a6c5-95a9434c3ec8",
|
||||
cy: "b8f1f76d-4ab9-4a2f-b294-e3623c6095a3"
|
||||
};
|
||||
|
||||
const REFERENCE = "PEDW-CONTACT-US";
|
||||
|
||||
const allowedSubjects = {
|
||||
plq: [
|
||||
"Questions about Planning legislation or policy",
|
||||
"Planning legislation query",
|
||||
"Ymholiad deddfwriaeth gynllunio"
|
||||
],
|
||||
ipq: [
|
||||
"Questions or comments about applications for major infrastructure projects",
|
||||
"Infrastructure procedure query",
|
||||
"Ymholiad gweithdrefn seilwaith"
|
||||
],
|
||||
pcpq: [
|
||||
"Questions or comments about planning and environmental appeals",
|
||||
"Planning casework procedure query",
|
||||
"Ymholiad gweithdrefn gwaith achos cynllunio"
|
||||
],
|
||||
pi: ["Query about using the Casework Portal", "Portal Issues", "Materion Porth"],
|
||||
appadvice: [
|
||||
"Advice How to submit an appeal",
|
||||
"Appeal submission advice",
|
||||
"Cyngor cyflwyno apêl"
|
||||
],
|
||||
repadvice: [
|
||||
"Advice How to comment on an appeal or application",
|
||||
"Representation submission advice",
|
||||
"Cyngor cyflwyno sylwadau"
|
||||
],
|
||||
ceq: [
|
||||
"Queries about forthcoming Hearing or Inquiry event",
|
||||
"Casework Events Query",
|
||||
"Ymholiad Digwyddiadau Gwaith Achos"
|
||||
],
|
||||
other: ["Other enquiry for PEDW", "Any Other Enquiries", "Unrhyw Ymholiadau Eraill"],
|
||||
postdec: [
|
||||
"Issues or questions about a case after the decision is issued",
|
||||
"Post Decision",
|
||||
"Ar ôl Penderfyniad"
|
||||
],
|
||||
comp: [
|
||||
"General Complaints of Compliments",
|
||||
"Complaints/Complements",
|
||||
"Cwynion/Canmoliaethau"
|
||||
]
|
||||
};
|
||||
|
||||
const allowedFields = new Set([
|
||||
"contactEmail",
|
||||
"contactSubject",
|
||||
"contactbody",
|
||||
"typeOfContact",
|
||||
"language"
|
||||
]);
|
||||
|
||||
const emailRegex =
|
||||
/^(?!.*(?:.+\.)?(?:burpcollaborator\.net|interactsh\.com|mailinator\.com|10minutemail\.com|yopmail\.com|trashmail\.com)$)(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}|(?:\[(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:.+)])$/;
|
||||
|
||||
// Origin checking is browser defence in depth only. It is not authentication and
|
||||
// does not prevent a direct HTTP client from attempting abuse.
|
||||
const hasTrustedOrigin = (req) => {
|
||||
const requestOrigin = req?.headers?.origin;
|
||||
|
||||
if (typeof requestOrigin !== "string" || requestOrigin === "null") {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const requestUrl = new URL(requestOrigin);
|
||||
if (requestOrigin !== requestUrl.origin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const trustedOrigins = [process.env.NEXTAUTH_URL, process.env.CY_API_ROOT]
|
||||
.filter(
|
||||
(configuredUrl) =>
|
||||
typeof configuredUrl === "string" && configuredUrl.length > 0
|
||||
)
|
||||
.map((configuredUrl) => new URL(configuredUrl).origin);
|
||||
|
||||
return trustedOrigins.includes(requestUrl.origin);
|
||||
} catch (_error) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const validationError = (res, code, message) =>
|
||||
respondError(res, { status: 400, code, message });
|
||||
|
||||
const isPlainObject = (value) => {
|
||||
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const prototype = Object.getPrototypeOf(value);
|
||||
return prototype === null || prototype?.constructor?.name === "Object";
|
||||
};
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
if (req.method !== "POST") {
|
||||
res.setHeader("Allow", "POST");
|
||||
return respondError(res, {
|
||||
status: 405,
|
||||
code: "METHOD_NOT_ALLOWED",
|
||||
message: "Method not allowed"
|
||||
});
|
||||
}
|
||||
|
||||
const contentType = req.headers?.["content-type"];
|
||||
if (
|
||||
typeof contentType !== "string" ||
|
||||
contentType.split(";", 1)[0].trim().toLowerCase() !== "application/json"
|
||||
) {
|
||||
return respondError(res, {
|
||||
status: 415,
|
||||
code: "UNSUPPORTED_MEDIA_TYPE",
|
||||
message: "Content-Type must be application/json"
|
||||
});
|
||||
}
|
||||
|
||||
if (!hasTrustedOrigin(req)) {
|
||||
return respondError(res, {
|
||||
status: 403,
|
||||
code: "FORBIDDEN",
|
||||
message: "Request not permitted"
|
||||
});
|
||||
}
|
||||
|
||||
const requestBody = req.body;
|
||||
if (!isPlainObject(requestBody)) {
|
||||
return validationError(
|
||||
res,
|
||||
"INVALID_REQUEST_BODY",
|
||||
"Request body must be a JSON object"
|
||||
);
|
||||
}
|
||||
|
||||
const requestFields = Object.keys(requestBody);
|
||||
if (
|
||||
requestFields.length !== allowedFields.size ||
|
||||
requestFields.some((field) => !allowedFields.has(field))
|
||||
) {
|
||||
return validationError(
|
||||
res,
|
||||
"INVALID_REQUEST_FIELDS",
|
||||
"Request must contain exactly the supported fields"
|
||||
);
|
||||
}
|
||||
|
||||
const contactEmail = sanitizeString(requestBody.contactEmail);
|
||||
const contactSubject = sanitizeString(requestBody.contactSubject);
|
||||
const contactBody = sanitizeString(requestBody.contactbody);
|
||||
const typeOfContact = requestBody.typeOfContact;
|
||||
const language = requestBody.language;
|
||||
|
||||
if (
|
||||
typeof requestBody.contactEmail !== "string" ||
|
||||
!isNonEmptyString(contactEmail) ||
|
||||
contactEmail.length > 200 ||
|
||||
!emailRegex.test(contactEmail)
|
||||
) {
|
||||
return validationError(
|
||||
res,
|
||||
"INVALID_CONTACT_EMAIL",
|
||||
"contactEmail must be a valid email address of 200 characters or fewer"
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
typeof typeOfContact !== "string" ||
|
||||
!Object.prototype.hasOwnProperty.call(allowedSubjects, typeOfContact)
|
||||
) {
|
||||
return validationError(
|
||||
res,
|
||||
"INVALID_CONTACT_TYPE",
|
||||
"typeOfContact is not supported"
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
typeof requestBody.contactbody !== "string" ||
|
||||
!isNonEmptyString(contactBody) ||
|
||||
contactBody.length > 800
|
||||
) {
|
||||
return validationError(
|
||||
res,
|
||||
"INVALID_CONTACT_BODY",
|
||||
"contactbody must contain between 1 and 800 characters"
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
typeof requestBody.contactSubject !== "string" ||
|
||||
!allowedSubjects[typeOfContact].includes(contactSubject)
|
||||
) {
|
||||
return validationError(
|
||||
res,
|
||||
"INVALID_CONTACT_SUBJECT",
|
||||
"contactSubject does not match typeOfContact"
|
||||
);
|
||||
}
|
||||
|
||||
if (language !== "en" && language !== "cy") {
|
||||
return validationError(
|
||||
res,
|
||||
"INVALID_LANGUAGE",
|
||||
"language must be either en or cy"
|
||||
);
|
||||
}
|
||||
|
||||
const personalisation = {
|
||||
contactEmail,
|
||||
contactSubject,
|
||||
contactbody: removeContactUsEmailLinks(contactBody),
|
||||
typeOfContact
|
||||
};
|
||||
|
||||
const NotifyClient = require("notifications-node-client").NotifyClient;
|
||||
const notifyClient = new NotifyClient(process.env.NOTIFY_API_KEY);
|
||||
|
||||
try {
|
||||
await notifyClient.sendEmail(TEMPLATE_IDS[language], contactEmail, {
|
||||
personalisation,
|
||||
reference: REFERENCE
|
||||
});
|
||||
|
||||
return respondSuccess(res, { sent: true });
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "CONTACT_US_CONFIRMATION_FAILED",
|
||||
message: "Failed to send Contact Us confirmation email"
|
||||
});
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user