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