reps raised with correct return url
This commit is contained in:
@@ -603,7 +603,7 @@ let MakeRepresentation = (props) => {
|
|||||||
<button
|
<button
|
||||||
className="govuk-button withChevron govuk-button-cta"
|
className="govuk-button withChevron govuk-button-cta"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => signIn("email")}
|
onClick={() => signIn()}
|
||||||
>
|
>
|
||||||
Sign in to raise representation
|
Sign in to raise representation
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -155,14 +155,7 @@ const authOptions = (locale, req) => {
|
|||||||
const personalisation = {
|
const personalisation = {
|
||||||
"emailAddress": email,
|
"emailAddress": email,
|
||||||
"signInLink": url,
|
"signInLink": url,
|
||||||
"signInLink":
|
|
||||||
newURL +
|
|
||||||
"/api/auth/callback/email?callbackUrl=" +
|
|
||||||
encodeURIComponent(newURL) +
|
|
||||||
"&token=" +
|
|
||||||
searchParams.get("token") +
|
|
||||||
"&email=" +
|
|
||||||
encodeURIComponent(email),
|
|
||||||
"linkExpiry": 10 * 60,
|
"linkExpiry": 10 * 60,
|
||||||
};
|
};
|
||||||
const reference = "PEDW-SIGNIN";
|
const reference = "PEDW-SIGNIN";
|
||||||
@@ -220,19 +213,21 @@ const authOptions = (locale, req) => {
|
|||||||
//console.log(user);
|
//console.log(user);
|
||||||
return Promise.resolve(session);
|
return Promise.resolve(session);
|
||||||
},
|
},
|
||||||
async redirect({ url, baseUrl }) {
|
// redirect({ url, baseUrl }) {
|
||||||
// // Allows relative callback URLs
|
// debugger;
|
||||||
// if (url.startsWith("/")) return `${baseUrl}${url}`;
|
// console.log("baseurl:", url, baseUrl);
|
||||||
// // Allows callback URLs on the same origin
|
// // Allows relative callback URLs
|
||||||
// else if (new URL(url).origin === baseUrl) return url;
|
// if (url.startsWith("/")) return `${baseUrl}${url}`;
|
||||||
let newURL =
|
// // Allows callback URLs on the same origin
|
||||||
locale == "cy"
|
// else if (new URL(url).origin === baseUrl) return url;
|
||||||
? process.env.CY_API_ROOT
|
// // let newURL =
|
||||||
: process.env.NEXTAUTH_URL;
|
// // locale == "cy"
|
||||||
//console.log("baseurl:", newURL);
|
// // ? process.env.CY_API_ROOT
|
||||||
//return baseUrl;
|
// // : process.env.NEXTAUTH_URL;
|
||||||
return newURL;
|
|
||||||
},
|
// //return baseUrl;
|
||||||
|
// // return newURL;
|
||||||
|
// },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
+35
-23
@@ -43,7 +43,7 @@ const SignIn = (props) => {
|
|||||||
<div className="govuk-grid-column-two-thirds ">
|
<div className="govuk-grid-column-two-thirds ">
|
||||||
<form
|
<form
|
||||||
method="post"
|
method="post"
|
||||||
action={"/api/auth/signin/email"}
|
action="/api/auth/signin/email"
|
||||||
>
|
>
|
||||||
<div className="govuk-form-group">
|
<div className="govuk-form-group">
|
||||||
<input
|
<input
|
||||||
@@ -90,32 +90,44 @@ const SignIn = (props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// export async function getServerSideProps(context) {
|
||||||
|
// //console.log("-1-1-1-1-", context.query.callbackUrl, context.locale);
|
||||||
|
// //console.log("------ " + context.query.callbackUrl);
|
||||||
|
// // setCookie(context, "next-auth.callback-url", context.query.callbackUrl, {
|
||||||
|
// // path: "/",
|
||||||
|
// // });
|
||||||
|
|
||||||
|
// const csrfToken = await getCsrfToken(context);
|
||||||
|
// let callback =
|
||||||
|
// context.locale != "cy"
|
||||||
|
// ? process.env.NEXTAUTH_URL
|
||||||
|
// : "https://" + process.env.I18N_DOMAIN + ":3000";
|
||||||
|
|
||||||
|
// context.query.callbackUrl = callback;
|
||||||
|
|
||||||
|
// let formURL =
|
||||||
|
// new URL(callback).protocol +
|
||||||
|
// "//" +
|
||||||
|
// new URL(callback).hostname +
|
||||||
|
// ":" +
|
||||||
|
// new URL(callback).port; // +
|
||||||
|
// // "/api/auth/signin/email";
|
||||||
|
|
||||||
|
// //console.log("******", formURL, callback, csrfToken);
|
||||||
|
// return {
|
||||||
|
// props: { csrfToken: csrfToken, callbackUrl: formURL, redirect: true },
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
export async function getServerSideProps(context) {
|
export async function getServerSideProps(context) {
|
||||||
//console.log("-1-1-1-1-", context.query.callbackUrl, context.locale);
|
|
||||||
//console.log("------ " + context.query.callbackUrl);
|
|
||||||
// setCookie(context, "next-auth.callback-url", context.query.callbackUrl, {
|
|
||||||
// path: "/",
|
|
||||||
// });
|
|
||||||
|
|
||||||
const csrfToken = await getCsrfToken(context);
|
const csrfToken = await getCsrfToken(context);
|
||||||
let callback =
|
console.log("-1-1-1-1-", context.query.callbackUrl, context.locale);
|
||||||
context.locale != "cy"
|
let formURL = context.query.callbackUrl;
|
||||||
? process.env.NEXTAUTH_URL
|
console.log("formUrl:", formURL);
|
||||||
: "https://" + process.env.I18N_DOMAIN + ":3000";
|
|
||||||
|
|
||||||
context.query.callbackUrl = callback;
|
formURL = typeof formURL == "undefined" ? null : formURL;
|
||||||
|
|
||||||
let formURL =
|
|
||||||
new URL(callback).protocol +
|
|
||||||
"//" +
|
|
||||||
new URL(callback).hostname +
|
|
||||||
":" +
|
|
||||||
new URL(callback).port; // +
|
|
||||||
// "/api/auth/signin/email";
|
|
||||||
|
|
||||||
//console.log("******", formURL, callback, csrfToken);
|
|
||||||
return {
|
return {
|
||||||
props: { csrfToken: csrfToken, callbackUrl: formURL, redirect: true },
|
props: { csrfToken: csrfToken, callbackUrl: formURL },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import Footer from "../../components/footer";
|
|||||||
import Header from "../../components/header";
|
import Header from "../../components/header";
|
||||||
import Case from "../../components/representation";
|
import Case from "../../components/representation";
|
||||||
import { wrapper } from "../../store/store";
|
import { wrapper } from "../../store/store";
|
||||||
import { getSession, useSession } from "next-auth/react";
|
import { getSession, useSession, signIn } from "next-auth/react";
|
||||||
import {
|
import {
|
||||||
consoleLogger,
|
consoleLogger,
|
||||||
getPersonalAccount,
|
getPersonalAccount,
|
||||||
@@ -69,11 +69,13 @@ const Home = (props) => {
|
|||||||
if (status === "loading") {
|
if (status === "loading") {
|
||||||
return <NoSessionWarning loading={true} />;
|
return <NoSessionWarning loading={true} />;
|
||||||
}
|
}
|
||||||
|
// console.log("unauthenticated path:", router.asPath);
|
||||||
if (status === "unauthenticated") {
|
// if (status === "unauthenticated") {
|
||||||
router.push("/auth/signin");
|
// console.log("unauthenticated path:", router.asPath);
|
||||||
return <NoSessionWarning />;
|
// signIn("email", { callbackUrl: router.asPath });
|
||||||
}
|
// //router.push("/auth/signin");
|
||||||
|
// return <NoSessionWarning />;
|
||||||
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
+1
-1
@@ -127,7 +127,7 @@ const makeStore = ({ isServer }) => {
|
|||||||
key: "acp",
|
key: "acp",
|
||||||
whitelist: [
|
whitelist: [
|
||||||
"currentView",
|
"currentView",
|
||||||
//"searchResultsObj",
|
"searchResultsObj",
|
||||||
//"appealType",
|
//"appealType",
|
||||||
"LPAData",
|
"LPAData",
|
||||||
//"accountDetails",
|
//"accountDetails",
|
||||||
|
|||||||
Reference in New Issue
Block a user