updated storage account stuff to take auth id

This commit is contained in:
2022-08-26 15:19:34 +01:00
parent 671d49c394
commit 862a953aae
18 changed files with 346 additions and 133 deletions
+12 -1
View File
@@ -1,6 +1,7 @@
import useTranslation from "next-translate/useTranslation";
import Head from "next/head";
import { getSession, useSession } from "next-auth/react";
import _ from "lodash";
import { useRouter } from "next/router";
import { connect } from "react-redux";
@@ -16,6 +17,7 @@ import Header from "../../components/header";
import CreateCase from "../../components/newappeal/createCase";
import {
setAccountDetails,
setContainerID,
setLoggedInUserId,
} from "../../store/accountDetails/action";
import { setAppealType } from "../../store/appealType/action";
@@ -120,7 +122,7 @@ const Home = (props) => {
appealType={props.setAppealType}
loggedInUser={props.accountDetails.loggedinUserId}
whichForm={props.form}
loggedInUserIdent={loggedInUserIdent}
containerID={props.accountDetails.containerID}
/>
</main>
</div>
@@ -141,6 +143,14 @@ export const getServerSideProps = wrapper.getServerSideProps(
let thisSession = await getSession(ctx);
console.log("nextAuth Session:", thisSession);
if (_.has(thisSession, "user") == false) {
return {
redirect: {
destination: "/error",
permanent: false,
},
};
}
let loggedInUserIdent = thisSession.user.id;
let loggedInUser = cookies.pinsUser;
@@ -163,6 +173,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
store.dispatch(setLPA(lpaData));
store.dispatch(setLoggedInUserId(loggedInUser));
store.dispatch(setAccountDetails(accountDetails));
store.dispatch(setContainerID(thisSession.user.id));
return {
props: { loggedInUserIdent: loggedInUserIdent },