updated authentication on protected pages

This commit is contained in:
2023-06-05 12:00:28 +01:00
parent 3dd4525770
commit 31375a5999
20 changed files with 408 additions and 119 deletions
+14
View File
@@ -28,6 +28,9 @@ import {
import { getAppealsTypes, getLPA } from "../../actions";
import { setLPA } from "../../store/lpa/action";
import { getSession, useSession } from "next-auth/react";
import NoSessionWarning from "../../components/nosession";
const Home = (props) => {
const { footerLinks, pages, formData } = props;
let { t, lang } = useTranslation();
@@ -39,6 +42,17 @@ const Home = (props) => {
const { appealType, LPAData } = props;
const [passwordUpdated, setPasswordUpdated] = useState(false);
const { data: session, status } = useSession();
if (status === "loading") {
return <NoSessionWarning loading={true} />;
}
if (status === "unauthenticated") {
router.push("/auth/signin");
return <NoSessionWarning />;
}
return (
<div>
<Head>
+14 -1
View File
@@ -17,9 +17,11 @@ import jsonpath from "jsonpath";
import { reduxForm, formValueSelector } from "redux-form";
import RegisterForm from "../../components/account/registerform";
import { getSession, useSession } from "next-auth/react";
import NoSessionWarning from "../../components/nosession";
const Home = (props) => {
const { footerLinks, formData } = props;
const { footerLinks } = props;
let { t, lang } = useTranslation();
const router = useRouter();
@@ -29,6 +31,17 @@ const Home = (props) => {
const [registerFormComplete, setRegisterFormComplete] = useState(false);
const [accountCreatedComplete, setAccountCreatedComplete] = useState(false);
const { data: session, status } = useSession();
if (status === "loading") {
return <NoSessionWarning loading={true} />;
}
if (status === "unauthenticated") {
router.push("/auth/signin");
return <NoSessionWarning />;
}
return (
<div>
<Head>
+13 -1
View File
@@ -15,7 +15,8 @@ import { useState } from "react";
import useTranslation from "next-translate/useTranslation";
import jsonpath from "jsonpath";
import { reduxForm, formValueSelector } from "redux-form";
import { getSession, useSession } from "next-auth/react";
import NoSessionWarning from "../../components/nosession";
import RegisterForm from "../../components/account/registerform";
const Home = (props) => {
@@ -29,6 +30,17 @@ const Home = (props) => {
const [registerFormComplete, setRegisterFormComplete] = useState(false);
const [accountCreatedComplete, setAccountCreatedComplete] = useState(false);
const { data: session, status } = useSession();
if (status === "loading") {
return <NoSessionWarning loading={true} />;
}
if (status === "unauthenticated") {
router.push("/auth/signin");
return <NoSessionWarning />;
}
return (
<div>
<Head>
+13
View File
@@ -20,6 +20,8 @@ import PersonalDetails from "../../components/account/personaldetails";
import { setAccountDetails } from "../../store/accountDetails/action";
import { getPersonalAccount } from "../../actions";
import { setCookie } from "nookies";
import { getSession, useSession } from "next-auth/react";
import NoSessionWarning from "../../components/nosession";
const Home = (props) => {
const { footerLinks, formData } = props;
@@ -36,6 +38,17 @@ const Home = (props) => {
setCookie(null, "pinsUser", props.accountDetails.loggedinUserId),
{ path: "/" };
const { data: session, status } = useSession();
if (status === "loading") {
return <NoSessionWarning loading={true} />;
}
if (status === "unauthenticated") {
router.push("/auth/signin");
return <NoSessionWarning />;
}
return (
<div>
<Head>
+15 -5
View File
@@ -162,11 +162,21 @@ export const getServerSideProps = wrapper.getServerSideProps(
let thisSession = await getSession(ctx);
console.log(
"auth sess for register :",
thisSession,
thisSession.user.email
);
// console.log(
// "auth sess for register :",
// thisSession,
// thisSession.user.email
// );
if (!thisSession) {
console.log("not has sesssion.......");
return {
redirect: {
destination: "/auth/signin",
permanent: false,
},
};
}
return {
props: {