updated authentication on protected pages
This commit is contained in:
+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