updated with oauth, footer docs,

This commit is contained in:
2021-11-30 07:22:07 +00:00
parent f9f7b777e7
commit af5354d19f
32 changed files with 4790 additions and 250 deletions
+52
View File
@@ -0,0 +1,52 @@
import Link from "next/link";
import Head from "next/head";
import Header from "../components/header";
import Banner from "../components/banner";
import CookieBanner from "../components/cookieBanner";
import useTranslation from "next-translate/useTranslation";
import Footer from "../components/footer";
function Error({ statusCode }, props) {
let { t, lang } = useTranslation();
const { footerLinks, pages } = props;
return (
<div>
<Head>
<title>
{t("case:page-title")} - {t("common:service-name")}
</title>
</Head>
<div id="page_wrapper">
<CookieBanner />
<Header courseName={t("common:service-name")} />
<div className="govuk-width-container govuk-!-padding-bottom-9">
<main className="govuk-main-wrapper govuk-!-padding-top-9 govuk-!-padding-bottom-9">
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds ">
<h1>{t("common:error-page-title")}</h1>
<p className="govuk-body">
{statusCode
? `An error ${statusCode} occurred on server`
: t("common:error-page-message")}
</p>
<Link href="/">
<a>Go back home</a>
</Link>
</div>
</div>
</main>
</div>
<Footer footerLinks={footerLinks} />
</div>
</div>
);
}
Error.getInitialProps = ({ res, err }) => {
const statusCode = res ? res.statusCode : err ? err.statusCode : 404;
console.log(res, err);
return { statusCode };
};
export default Error;
+1 -1
View File
@@ -9,7 +9,7 @@ class MyDocument extends Document {
let useGATracking = false;
// remove this block when not need after softlaunch
//remove this block when not need after softlaunch
let hasBasicAuth =
typeof process.env.BASIC_AUTH_CREDENTIALS != "undefined";
+19 -12
View File
@@ -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
+15
View File
@@ -140,6 +140,21 @@ export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
let token = await getToken();
var tokenIssuedAt = new Date();
var tokenExpiryTimeAt = new Date();
tokenExpiryTimeAt.setSeconds(
tokenExpiryTimeAt.getSeconds() + token.expires_in
);
console.log(
"token issued:",
tokenIssuedAt.toUTCString(),
"\n",
"token expires:",
tokenExpiryTimeAt.toUTCString()
);
console.log(token);
token = token.access_token;
const [appealTypeData, lpaData] = await Promise.all([
+30 -18
View File
@@ -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();
}
+21
View File
@@ -123,7 +123,28 @@ export const getServerSideProps = wrapper.getServerSideProps(
async ({ query, req, res }) => {
console.log("query-", query);
res.setHeader(
"Cache-Control",
"public, s-maxage=10, stale-while-revalidate=59"
);
let token = await getToken();
var tokenIssuedAt = new Date();
var tokenExpiryTimeAt = new Date();
tokenExpiryTimeAt.setSeconds(
tokenExpiryTimeAt.getSeconds() + token.expires_in
);
console.log(
"token issued:",
tokenIssuedAt.toUTCString(),
"\n",
"token expires:",
tokenExpiryTimeAt.toUTCString()
);
console.log(token);
token = token.access_token;
let searchResultsObj = await getBasicDNSSearch(token);
+16
View File
@@ -122,6 +122,22 @@ export const getServerSideProps = wrapper.getServerSideProps(
console.log("query-", query);
let token = await getToken();
var tokenIssuedAt = new Date();
var tokenExpiryTimeAt = new Date();
tokenExpiryTimeAt.setSeconds(
tokenExpiryTimeAt.getSeconds() + token.expires_in
);
console.log(
"token issued:",
tokenIssuedAt.toUTCString(),
"\n",
"token expires:",
tokenExpiryTimeAt.toUTCString()
);
console.log(token);
token = token.access_token;
let searchResultsObj = await getBasicSearch(token, query.q);