updated authentication on protected pages
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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
@@ -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 },
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user