diff --git a/components/case/representation/index.js b/components/case/representation/index.js index ed88c415..c45243c8 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -603,7 +603,7 @@ let MakeRepresentation = (props) => { diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index b32ee5db..4797e73c 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -155,14 +155,7 @@ const authOptions = (locale, req) => { const personalisation = { "emailAddress": email, "signInLink": url, - "signInLink": - newURL + - "/api/auth/callback/email?callbackUrl=" + - encodeURIComponent(newURL) + - "&token=" + - searchParams.get("token") + - "&email=" + - encodeURIComponent(email), + "linkExpiry": 10 * 60, }; const reference = "PEDW-SIGNIN"; @@ -220,19 +213,21 @@ const authOptions = (locale, req) => { //console.log(user); return Promise.resolve(session); }, - async redirect({ url, baseUrl }) { - // // Allows relative callback URLs - // if (url.startsWith("/")) return `${baseUrl}${url}`; - // // Allows callback URLs on the same origin - // else if (new URL(url).origin === baseUrl) return url; - let newURL = - locale == "cy" - ? process.env.CY_API_ROOT - : process.env.NEXTAUTH_URL; - //console.log("baseurl:", newURL); - //return baseUrl; - return newURL; - }, + // redirect({ url, baseUrl }) { + // debugger; + // console.log("baseurl:", url, baseUrl); + // // Allows relative callback URLs + // if (url.startsWith("/")) return `${baseUrl}${url}`; + // // Allows callback URLs on the same origin + // else if (new URL(url).origin === baseUrl) return url; + // // let newURL = + // // locale == "cy" + // // ? process.env.CY_API_ROOT + // // : process.env.NEXTAUTH_URL; + + // //return baseUrl; + // // return newURL; + // }, }, }; }; diff --git a/pages/auth/signin.js b/pages/auth/signin.js index fecd8682..305af5f3 100644 --- a/pages/auth/signin.js +++ b/pages/auth/signin.js @@ -43,7 +43,7 @@ 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) { - //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"; + console.log("-1-1-1-1-", context.query.callbackUrl, context.locale); + let formURL = context.query.callbackUrl; + console.log("formUrl:", formURL); - 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); + formURL = typeof formURL == "undefined" ? null : formURL; return { - props: { csrfToken: csrfToken, callbackUrl: formURL, redirect: true }, + props: { csrfToken: csrfToken, callbackUrl: formURL }, }; } diff --git a/pages/myportal/representation.js b/pages/myportal/representation.js index cdc89231..9c132f17 100644 --- a/pages/myportal/representation.js +++ b/pages/myportal/representation.js @@ -10,7 +10,7 @@ import Footer from "../../components/footer"; import Header from "../../components/header"; import Case from "../../components/representation"; import { wrapper } from "../../store/store"; -import { getSession, useSession } from "next-auth/react"; +import { getSession, useSession, signIn } from "next-auth/react"; import { consoleLogger, getPersonalAccount, @@ -69,11 +69,13 @@ const Home = (props) => { if (status === "loading") { return ; } - - if (status === "unauthenticated") { - router.push("/auth/signin"); - return ; - } + // console.log("unauthenticated path:", router.asPath); + // if (status === "unauthenticated") { + // console.log("unauthenticated path:", router.asPath); + // signIn("email", { callbackUrl: router.asPath }); + // //router.push("/auth/signin"); + // return ; + // } return (
diff --git a/store/store.js b/store/store.js index 6164ca08..dd4d0279 100644 --- a/store/store.js +++ b/store/store.js @@ -127,7 +127,7 @@ const makeStore = ({ isServer }) => { key: "acp", whitelist: [ "currentView", - //"searchResultsObj", + "searchResultsObj", //"appealType", "LPAData", //"accountDetails",