updated login and register to use oauth
This commit is contained in:
+12
-34
@@ -110,7 +110,9 @@ const hashAPIPath = (queryPath) => {
|
||||
);
|
||||
hashlink = hashlink.toString(CryptoJS.enc.Hex);
|
||||
|
||||
return "&hash=" + hashlink;
|
||||
//return "&hash=" + hashlink;
|
||||
|
||||
return (hashPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
||||
};
|
||||
|
||||
export const getBasicSearch = (token, searchString) => {
|
||||
@@ -990,19 +992,11 @@ export const getEmailAccountCheck = (emailAddress) => {
|
||||
};
|
||||
|
||||
export const createAccount = (formValues) => {
|
||||
var data = JSON.stringify(formValues);
|
||||
var data = formValues; //JSON.stringify(formValues);
|
||||
var queryUrl = "/api/proxy/contacts";
|
||||
var config = {
|
||||
method: "post",
|
||||
url: queryUrl + hashAPIPath(queryUrl),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": getToken(),
|
||||
},
|
||||
data: data,
|
||||
};
|
||||
// console.log(config);
|
||||
@@ -1016,48 +1010,32 @@ export const createAccount = (formValues) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const updateAccount = (contactId, updateBody) => {
|
||||
var data = JSON.stringify(updateBody);
|
||||
export const updateAccount = async (contactId, updateBody) => {
|
||||
var data = updateBody; //JSON.stringify(updateBody);
|
||||
var queryUrl = "/api/proxy/contacts(" + contactId + ")";
|
||||
queryUrl = queryUrl + hashAPIPath(queryUrl);
|
||||
var config = {
|
||||
method: "patch",
|
||||
url: queryUrl + hashAPIPath(queryUrl),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": getToken(),
|
||||
},
|
||||
url: queryUrl,
|
||||
data: data,
|
||||
};
|
||||
// console.log(config);
|
||||
return axios(config)
|
||||
.then((res) => {
|
||||
//console.log("posted ", res.data);
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("this serror", error);
|
||||
console.log("this error:", error);
|
||||
});
|
||||
};
|
||||
|
||||
export const updatePassword = (contactId, newpassword) => {
|
||||
let updateBody = { "pinswg_custom_password": newpassword };
|
||||
var data = JSON.stringify(updateBody);
|
||||
var data = updateBody; //JSON.stringify(updateBody);
|
||||
var queryUrl = "/api/proxy/contacts(" + contactId + ")";
|
||||
queryUrl = queryUrl + hashAPIPath(queryUrl);
|
||||
var config = {
|
||||
method: "patch",
|
||||
url: queryUrl + hashAPIPath(queryUrl),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": getToken(),
|
||||
},
|
||||
url: queryUrl,
|
||||
data: data,
|
||||
};
|
||||
// console.log(config);
|
||||
|
||||
@@ -75,52 +75,70 @@ const RegisterComplete = (props) => {
|
||||
}
|
||||
});
|
||||
|
||||
return props.accountDetails.accCr == "created" ? (
|
||||
<>
|
||||
<p className="govuk-body">
|
||||
{t("account:register-new-account-confirmation-email")}
|
||||
</p>
|
||||
var registerBody = "";
|
||||
switch (props.accountDetails.accCr) {
|
||||
case "created":
|
||||
return (registerBody = (
|
||||
<>
|
||||
<p className="govuk-body">
|
||||
{t("account:register-new-account-confirmation-email")}
|
||||
</p>
|
||||
|
||||
<h2 className="govuk-heading-m">
|
||||
{t("account:register-new-account-sub-heading-what-next")}
|
||||
</h2>
|
||||
<h2 className="govuk-heading-m">
|
||||
{t(
|
||||
"account:register-new-account-sub-heading-what-next"
|
||||
)}
|
||||
</h2>
|
||||
|
||||
<p className="govuk-body">
|
||||
{t("account:register-new-account-paragraph-what-next")}
|
||||
</p>
|
||||
<p className="govuk-body">
|
||||
{t("account:register-new-account-paragraph-what-next")}
|
||||
</p>
|
||||
|
||||
<p className="govuk-body">
|
||||
<Link href="/">
|
||||
<a
|
||||
className="govuk-link"
|
||||
onClick={() => {
|
||||
setLogout(), window.localStorage.clear();
|
||||
}}
|
||||
>
|
||||
{t("account:register-new-account-my-portal-link")}
|
||||
</a>
|
||||
</Link>
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<h2 className="govuk-heading-m">
|
||||
{t("account:register-new-account-account-failed")}
|
||||
</h2>
|
||||
<p className="govuk-body">
|
||||
<a
|
||||
onClick={() => {
|
||||
setRegisterFormComplete(false),
|
||||
setAccountCreatedComplete(false),
|
||||
setAccCr("false");
|
||||
}}
|
||||
className="govuk-link"
|
||||
>
|
||||
Try registering again
|
||||
</a>
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
<p className="govuk-body">
|
||||
<Link href="/">
|
||||
<a
|
||||
className="govuk-link"
|
||||
onClick={() => {
|
||||
setLogout(), window.localStorage.clear();
|
||||
}}
|
||||
>
|
||||
{t(
|
||||
"account:register-new-account-my-portal-link"
|
||||
)}
|
||||
</a>
|
||||
</Link>
|
||||
</p>
|
||||
</>
|
||||
));
|
||||
|
||||
break;
|
||||
|
||||
case "exists":
|
||||
return (registerBody = (
|
||||
<>
|
||||
<h2 className="govuk-heading-m">
|
||||
{t("account:register-new-account-account-failed")}
|
||||
</h2>
|
||||
<p className="govuk-body">
|
||||
<a
|
||||
onClick={() => {
|
||||
setRegisterFormComplete(false),
|
||||
setAccountCreatedComplete(false),
|
||||
setAccCr(false);
|
||||
}}
|
||||
className="govuk-link"
|
||||
>
|
||||
Try registering again
|
||||
</a>
|
||||
</p>
|
||||
</>
|
||||
));
|
||||
|
||||
default:
|
||||
return (registerBody = "");
|
||||
break;
|
||||
}
|
||||
return registerBody;
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
|
||||
@@ -109,7 +109,7 @@ const RegisterForm = (props) => {
|
||||
setRegisterFormComplete(true);
|
||||
};
|
||||
|
||||
console.log(pristine);
|
||||
//console.log(pristine);
|
||||
return (
|
||||
<>
|
||||
{!pristine && !valid && (
|
||||
|
||||
@@ -24,41 +24,46 @@ const RenderTextfield = ({
|
||||
input,
|
||||
hint1,
|
||||
hint2,
|
||||
hint3,
|
||||
meta: { touched, error },
|
||||
...custom
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={
|
||||
touched && error
|
||||
? "govuk-form-group govuk-form-group--error"
|
||||
: "govuk-form-group "
|
||||
}
|
||||
>
|
||||
<div className="govuk-form-group">
|
||||
<div id="basicSearch-hint" className="govuk-hint ">
|
||||
<label
|
||||
className="govuk-label "
|
||||
htmlFor={id}
|
||||
id={id + "_label"}
|
||||
>
|
||||
{label}
|
||||
<span className="govuk-body-m">{hint1}</span>
|
||||
<span className="govuk-body-s">{hint1}</span>
|
||||
</label>
|
||||
|
||||
<br />
|
||||
<span className="govuk-body-s">
|
||||
{hint2} CAS-00009-W8N6W4
|
||||
</span>
|
||||
<ul className="govuk-body-s govuk-!-margin-top-3">
|
||||
<li>{hint2} </li>
|
||||
<li>{hint3}</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{touched && error && (
|
||||
<span id={id + "-error"} className="govuk-error-message">
|
||||
<span className="govuk-visually-hidden">Error:</span>{" "}
|
||||
{error}
|
||||
</span>
|
||||
)}
|
||||
<input {...input} className={className} name={name} id={id} />
|
||||
<div>
|
||||
<input
|
||||
{...input}
|
||||
className={className}
|
||||
name={name}
|
||||
id={id}
|
||||
/>
|
||||
{touched && error && (
|
||||
<span
|
||||
id={id + "-error"}
|
||||
className="govuk-error-message govuk-form-group--error"
|
||||
>
|
||||
<span className="govuk-visually-hidden">
|
||||
Error:
|
||||
</span>{" "}
|
||||
{error}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
@@ -121,7 +126,10 @@ let CaseSearch = (props) => {
|
||||
aria-describedby="basicSearch-hint"
|
||||
hint1={t("myportal:searchcases-card-search-hint")}
|
||||
hint2={t(
|
||||
"myportal:searchcases-card-search-example-label"
|
||||
"myportal:searchcases-card-search-example-label-1"
|
||||
)}
|
||||
hint3={t(
|
||||
"myportal:searchcases-card-search-example-label-2"
|
||||
)}
|
||||
/>
|
||||
|
||||
|
||||
@@ -218,16 +218,16 @@ const TopThree = (props) => {
|
||||
let noRecordsLabel = "";
|
||||
switch (topThreeType) {
|
||||
case "watchedCases":
|
||||
noRecordsLabel = "You are not watching any cases";
|
||||
noRecordsLabel = t("myportal:norecords-watched-cases");
|
||||
break;
|
||||
case "myRepresentations":
|
||||
noRecordsLabel = "You have no representations";
|
||||
noRecordsLabel = t("myportal:norecords-representations");
|
||||
break;
|
||||
case "myCases":
|
||||
noRecordsLabel = "You have no cases";
|
||||
noRecordsLabel = t("myportal:norecords-cases");
|
||||
break;
|
||||
case "awaitingSubmission":
|
||||
noRecordsLabel = "You have no awaiting submissions";
|
||||
noRecordsLabel = t("myportal:norecords-awaiting-submissions");
|
||||
break;
|
||||
}
|
||||
return (
|
||||
|
||||
@@ -33,6 +33,7 @@ module.exports = {
|
||||
"/dnsdetails": ["case", "search", "dnsCommon", "dnsApplications"],
|
||||
"/help/cookies": ["common", "cookies"],
|
||||
"/account/register": ["common", "account"],
|
||||
"/account/personaldetails": ["common", "search"],
|
||||
"/details-about-cookies": ["common", "cookies"],
|
||||
"/terms-and-conditions": ["common"],
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"register-new-account-heading": "Creu cyfrif newydd",
|
||||
"register-new-account-status-created-label": "Nid yw'ch cyfrif wedi creu",
|
||||
"register-new-account-status-not-created-label": "Mae eich cyfrif wedi'i greu",
|
||||
"register-new-account-status-created-label": "Mae eich cyfrif wedi'i greu",
|
||||
"register-new-account-status-not-created-label": "Nid yw'ch cyfrif wedi creu",
|
||||
"register-new-account-checking-label": "Gwirio am gyfrif...",
|
||||
"help-heading": "Help",
|
||||
"help-sub-heading-1": "Cwmnïau neu gyflwyniadau gan fwy nag un unigolyn (grwpiau)",
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
"makenewappeal-card-paragraph-two": "Wedi i chi glicio'r botwm 'gwneud apêl newydd' isod, cewch eich arwain drwy broses i'ch helpu i ddewis y math cywir o apêl.",
|
||||
"makenewappeal-card-button-label": "Gwneud apêl newydd",
|
||||
"mycases-card-title": "Fy achosion",
|
||||
"searchcases-card-title": "Chwilio am ddogfennau apêl",
|
||||
"searchcases-card-search-hint": "Chwiliwch drwy roi cyfeirnod 7 digid yr achos",
|
||||
"searchcases-card-search-example-label": "Enghraifft:",
|
||||
"searchcases-card-button": "Cyflwyno Chwiliad",
|
||||
"searchcases-card-title": "Chwilio apeliadau a Datblygiadau o Arwyddocâd Cenedlaethol",
|
||||
"searchcases-card-search-hint": "Defnyddiwch gyfeimod yr achos neu deitl DAC i chwilio. Bydd cyfeirnod yr achos yn debyg i un o'r canlynol:",
|
||||
"searchcases-card-search-example-label-1": "APP-A12345-A-21-1234567",
|
||||
"searchcases-card-search-example-label-2": "CAS-12345-A1B2C3",
|
||||
"searchcases-card-button": "Cyflwyno chwiliad",
|
||||
"searchcases-card-advanced-link": "Chwiliad uwch",
|
||||
"searchcases-validation-required": "Angenrheidiol",
|
||||
"searchcases-validation-minlength": "Rhaid bod yn 4 nod neu fwy",
|
||||
@@ -25,5 +26,9 @@
|
||||
"yourdetails-card-link": "Gweld manylion eich cyfrif",
|
||||
"changepassword-card-title": "Newid eich cyfrinair",
|
||||
"changepassword-card-paragraph-one": "Gallwch chi newid eich cyfrinair",
|
||||
"changepassword-card-link": "Diweddarwch eich cyfrinair"
|
||||
"changepassword-card-link": "Diweddarwch eich cyfrinair",
|
||||
"norecords-cases": "Nid oes gennych unrhyw achosion",
|
||||
"norecords-representations": "Nid oes gennych unrhyw sylwadau",
|
||||
"norecords-watched-cases": "Nid ydych yn gwylio unrhyw achosion",
|
||||
"norecords-awaiting-submission": "Nid oes gennych unrhyw gyflwyniadau sy'n aros"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"register-new-account-heading": "Create a new account",
|
||||
"register-new-account-status-created-label": "Your account has not created",
|
||||
"register-new-account-status-not-created-label": "Your account has been created",
|
||||
"register-new-account-status-created-label": "Your account has created",
|
||||
"register-new-account-status-not-created-label": "Your account has not been created",
|
||||
"register-new-account-checking-label": "Checking for account...",
|
||||
"help-heading": "Help",
|
||||
"help-sub-heading-1": "Companies or submissions by more than one individual (groups)",
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
"makenewappeal-card-paragraph-two": "Once you click the 'make a new appeal' button below you will be guided through a process to help you select the correct appeal type",
|
||||
"makenewappeal-card-button-label": "Make a new appeal",
|
||||
"mycases-card-title": "My cases",
|
||||
"searchcases-card-title": "Appeal documentation search",
|
||||
"searchcases-card-search-hint": "Search by entering the 7 digit case reference number",
|
||||
"searchcases-card-search-example-label": "Example",
|
||||
"searchcases-card-title": "Search appeals and Developments of National Significance",
|
||||
"searchcases-card-search-hint": "Use the case reference or DNS title to search. Case reference will be similar to one of the following:",
|
||||
"searchcases-card-search-example-label-1": "APP-A12345-A-21-1234567",
|
||||
"searchcases-card-search-example-label-2": "CAS-12345-A1B2C3",
|
||||
"searchcases-card-button": "Submit Search",
|
||||
"searchcases-card-advanced-link": "Advanced Search",
|
||||
"searchcases-validation-required": "Required",
|
||||
@@ -25,5 +26,9 @@
|
||||
"yourdetails-card-link": "View your account details",
|
||||
"changepassword-card-title": "Change your password",
|
||||
"changepassword-card-paragraph-one": "You can change your password",
|
||||
"changepassword-card-link": "Update your password"
|
||||
"changepassword-card-link": "Update your password",
|
||||
"norecords-cases": "You have no cases",
|
||||
"norecords-representations": "You have no representations",
|
||||
"norecords-watched-cases": "You are not watching any cases",
|
||||
"norecords-awaiting-submission": "You have no awaiting submissions"
|
||||
}
|
||||
+19
-12
@@ -61,19 +61,26 @@ const Home = (props) => {
|
||||
</h1>
|
||||
) : (
|
||||
<h1>
|
||||
{props.accountDetails.accCr !=
|
||||
"false"
|
||||
? props.accountDetails
|
||||
.accCr == "exists"
|
||||
? t(
|
||||
"account:register-new-account-status-not-created-label"
|
||||
)
|
||||
: t(
|
||||
"account:register-new-account-status-created-label"
|
||||
)
|
||||
: t(
|
||||
{console.log(
|
||||
props.accountDetails.accCr
|
||||
)}
|
||||
|
||||
{props.accountDetails.accCr ===
|
||||
false
|
||||
? t(
|
||||
"account:register-new-account-checking-label"
|
||||
)}
|
||||
)
|
||||
: props.accountDetails
|
||||
.accCr === "created"
|
||||
? t(
|
||||
"account:register-new-account-status-created-label"
|
||||
)
|
||||
: props.accountDetails
|
||||
.accCr === "exists"
|
||||
? t(
|
||||
"account:register-new-account-status-not-created-label"
|
||||
)
|
||||
: "wewer"}
|
||||
</h1>
|
||||
)}
|
||||
<RegisterForm
|
||||
|
||||
@@ -70,28 +70,38 @@ function checkProxyPath(queryPath) {
|
||||
}
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var data = JSON.stringify(req.body);
|
||||
var data = req.body; //JSON.stringify(req.body);
|
||||
var accessToken = await getToken();
|
||||
accessToken = accessToken.access_token;
|
||||
|
||||
const isDocument = req.url.indexOf("/documents/download") > -1;
|
||||
|
||||
let hashCheckPath = isDocument
|
||||
? req.url.split("?hash=")[0]
|
||||
: req.url.split("&hash=")[0];
|
||||
let hashCheckValue = isDocument
|
||||
? req.url.split("?hash=")[1]
|
||||
: req.url.split("&hash=")[1];
|
||||
let hashCheckPath =
|
||||
req.url.indexOf("?hash=") > -1
|
||||
? req.url.split("?hash=")[0]
|
||||
: req.url.split("&hash=")[0];
|
||||
|
||||
let hashCheckValue =
|
||||
req.url.indexOf("?hash=") > -1
|
||||
? req.url.split("?hash=")[1]
|
||||
: req.url.split("&hash=")[1];
|
||||
|
||||
let hashFromRequest = checkProxyPath(hashCheckPath);
|
||||
|
||||
let proxyDestinationURL =
|
||||
PROXY_RELAY_URL +
|
||||
(req.url.indexOf("?hash=") > -1
|
||||
? req.url.split("?hash=")[0]
|
||||
: req.url.split("&hash=")[0]
|
||||
).split("/api/proxy/")[1] +
|
||||
(req.url.indexOf("?hash=") > -1
|
||||
? "?hash=" + req.url.split("?hash=")[1]
|
||||
: "&hash=" + req.url.split("&hash=")[1]);
|
||||
|
||||
var configNoData = {
|
||||
method: req.method,
|
||||
//url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")",
|
||||
url:
|
||||
PROXY_RELAY_URL +
|
||||
req.url.split("&hash=")[0].split("/api/proxy/")[1] +
|
||||
"&hash=" +
|
||||
req.url.split("&hash=")[1],
|
||||
url: proxyDestinationURL,
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -105,11 +115,7 @@ export default async function ApiProxy(req, res) {
|
||||
|
||||
var config = {
|
||||
method: req.method,
|
||||
url:
|
||||
PROXY_RELAY_URL +
|
||||
req.query.route[0] +
|
||||
"&hash=" +
|
||||
req.url.split("&hash=")[1],
|
||||
url: proxyDestinationURL,
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -145,7 +151,9 @@ export default async function ApiProxy(req, res) {
|
||||
hashCheckPath.indexOf("/download") > 0 ? true : false;
|
||||
|
||||
axios(
|
||||
req.method == "GET"
|
||||
req.method == "PATCH"
|
||||
? config
|
||||
: req.method == "GET"
|
||||
? hasDocument
|
||||
? configDocument
|
||||
: configNoData
|
||||
@@ -177,6 +185,10 @@ export default async function ApiProxy(req, res) {
|
||||
});
|
||||
});
|
||||
} else {
|
||||
console.log(
|
||||
"no matching hash",
|
||||
hashCheckValue + " - " + hashFromRequest
|
||||
);
|
||||
res.status(405).end();
|
||||
return resolve();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user