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
+10
View File
@@ -225,6 +225,16 @@ export const getServerSideProps = wrapper.getServerSideProps(
let thisSession = await getSession(ctx);
//console.log("nextAuth Session:", thisSession);
if (!thisSession) {
console.log("not has sesssion.......");
return {
redirect: {
destination: "/auth/signin",
permanent: false,
},
};
}
let loggedInUserIdent = thisSession.user.id;
let loggedInUserEmail = thisSession.user.email;
+14
View File
@@ -9,6 +9,7 @@ import Header from "../../components/header";
import Aboutyou from "../../components/newappeal/aboutyou";
import CreateCase from "../../components/newappeal/createCase";
import { wrapper } from "../../store/store";
import { getSession, useSession } from "next-auth/react";
const AboutYou = (props) => {
const { footerLinks, pages, formData } = props;
@@ -118,6 +119,19 @@ export const getServerSideProps = wrapper.getServerSideProps(
console.log(cookies);
let loggedInUser = cookies.pinsUser;
let thisSession = await getSession(ctx);
//console.log("nextAuth Session:", thisSession);
if (!thisSession) {
console.log("not has sesssion.......");
return {
redirect: {
destination: "/auth/signin",
permanent: false,
},
};
}
}
);
+40 -27
View File
@@ -141,39 +141,52 @@ export const getServerSideProps = wrapper.getServerSideProps(
let thisSession = await getSession(ctx);
//console.log("nextAuth Session:", thisSession);
if (_.has(thisSession, "user") == false) {
// if (_.has(thisSession, "user") == false) {
// return {
// redirect: {
// destination: "/error",
// permanent: false,
// },
// };
// }
if (!thisSession) {
console.log("not has sesssion.......");
return {
redirect: {
destination: "/error",
destination: "/auth/signin",
permanent: false,
},
};
} else {
let loggedInUserIdent = thisSession.user.id;
let loggedInUser = cookies.pinsUser;
console.log("has loggedInUser", loggedInUser);
const [appealTypeData, lpaData, accountDetails] = await Promise.all(
[
await getAppealsTypesForNewAppeal(),
await getLPA(),
await getPersonalAccount(loggedInUser),
]
);
console.log("wewerwe s s", accountDetails);
// const lpaData = require("../../data/lpa.json");
// const appealTypeData = require("../../data/appealtypes.json");
store.dispatch(setAppealType(appealTypeData));
store.dispatch(setLPA(lpaData));
store.dispatch(setLoggedInUserId(loggedInUser));
store.dispatch(setAccountDetails(accountDetails));
store.dispatch(setContainerID(thisSession.user.id));
return {
props: { loggedInUserIdent: loggedInUserIdent },
};
}
let loggedInUserIdent = thisSession.user.id;
let loggedInUser = cookies.pinsUser;
console.log("has loggedInUser", loggedInUser);
const [appealTypeData, lpaData, accountDetails] = await Promise.all([
await getAppealsTypesForNewAppeal(),
await getLPA(),
await getPersonalAccount(loggedInUser),
]);
console.log("wewerwe s s", accountDetails);
// const lpaData = require("../../data/lpa.json");
// const appealTypeData = require("../../data/appealtypes.json");
store.dispatch(setAppealType(appealTypeData));
store.dispatch(setLPA(lpaData));
store.dispatch(setLoggedInUserId(loggedInUser));
store.dispatch(setAccountDetails(accountDetails));
store.dispatch(setContainerID(thisSession.user.id));
return {
props: { loggedInUserIdent: loggedInUserIdent },
};
}
);