diff --git a/pages/myportal/index.js b/pages/myportal/index.js
index 68ea59c3..08bcfe3e 100644
--- a/pages/myportal/index.js
+++ b/pages/myportal/index.js
@@ -207,6 +207,31 @@ export const getServerSideProps = wrapper.getServerSideProps(
// awaitingSubmissionFromBlob.case
// );
+ console.log(
+ "preferred language:",
+ accountDetails.pinswg_preferredlanguage
+ );
+
+ console.log(
+ "locale :",
+ accountDetails.pinswg_preferredlanguage == "846040000" ? "cy" : "en"
+ );
+
+ console.log("req locale :", ctx.locale);
+
+ const preferredLocale =
+ accountDetails.pinswg_preferredlanguage == "846040000"
+ ? "cy"
+ : "en";
+
+ // if (preferredLocale != ctx.locale) {
+ // return {
+ // redirect: {
+ // destination: "/cy/myportal",
+ // permanent: false,
+ // },
+ // };
+ // } else {
if (_.has(accountDetails, "errorCode") != false) {
return {
redirect: {
@@ -255,6 +280,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
},
};
}
+ // }
}
);
diff --git a/pages/myportal/representation.js b/pages/myportal/representation.js
index 07e73ca5..cdc89231 100644
--- a/pages/myportal/representation.js
+++ b/pages/myportal/representation.js
@@ -28,6 +28,8 @@ import {
setLoggedInUserId,
} from "../../store/accountDetails/action";
+import NoSessionWarning from "../../components/nosession";
+
const Home = (props) => {
const { footerLinks, pages } = props;
let { t, lang } = useTranslation();
@@ -62,6 +64,17 @@ const Home = (props) => {
updateAccountStore();
}, [dispatch]);
+ const { data: session, status } = useSession();
+
+ if (status === "loading") {
+ return
;
+ }
+
+ if (status === "unauthenticated") {
+ router.push("/auth/signin");
+ return
diff --git a/pages/myportal/searchresults.js b/pages/myportal/searchresults.js
index 243eb28a..0109ae06 100644
--- a/pages/myportal/searchresults.js
+++ b/pages/myportal/searchresults.js
@@ -84,51 +84,61 @@ export const getServerSideProps = wrapper.getServerSideProps(
let thisSession = await getSession(ctx);
- let [searchResultsObj, loggedInUser] = await Promise.all([
- await getBasicSearch(query.q),
- await getPortalLogin(thisSession.user.email),
- ]);
-
- const showReps = process.env.SHOWREPRESENTATIONS || false;
- const showLoginCheck = process.env.SHOWLOGIN || false;
- store.dispatch(setShowReps(showReps, showLoginCheck));
-
- console.log("env var ", process.env.SHOWREPRESENTATIONS);
- store.dispatch(setShowReps(showReps, showLoginCheck));
-
- searchResultsObj =
- searchResultsObj.status == 502
- ? {
- value: [],
- errorCode: searchResultsObj.status,
- errorMsg: searchResultsObj.statusText,
- }
- : searchResultsObj;
-
- //console.log("sssss", searchResultsObj);
-
- loggedInUser = loggedInUser.value[0].contactid;
-
- const watchedCases = await getWatchedCases(loggedInUser);
-
- console.log("sssss", loggedInUser);
-
- const [accountDetails, searchDetailsObj, watchedCasesDetails] =
- await Promise.all([
- await getPersonalAccount(loggedInUser),
- await getSearchDetails(searchResultsObj),
- await getDetails(watchedCases, "myWatchedCases"),
+ if (!thisSession) {
+ console.log("not has sesssion.......");
+ return {
+ redirect: {
+ destination: "/auth/signin",
+ permanent: false,
+ },
+ };
+ } else {
+ let [searchResultsObj, loggedInUser] = await Promise.all([
+ await getBasicSearch(query.q),
+ await getPortalLogin(thisSession.user.email),
]);
- store.dispatch(setAccountDetails(accountDetails));
- store.dispatch(setSearchResults(searchResultsObj));
- store.dispatch(setSearchDetails(searchDetailsObj));
- store.dispatch(setSearch(query.q));
- store.dispatch(setWatchedCases(watchedCases));
- store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
- store.dispatch(setLoggedInUserId(loggedInUser));
- thisSession != false &&
- store.dispatch(setContainerID(thisSession.user.id));
+ const showReps = process.env.SHOWREPRESENTATIONS || false;
+ const showLoginCheck = process.env.SHOWLOGIN || false;
+ store.dispatch(setShowReps(showReps, showLoginCheck));
+
+ console.log("env var ", process.env.SHOWREPRESENTATIONS);
+ store.dispatch(setShowReps(showReps, showLoginCheck));
+
+ searchResultsObj =
+ searchResultsObj.status == 502
+ ? {
+ value: [],
+ errorCode: searchResultsObj.status,
+ errorMsg: searchResultsObj.statusText,
+ }
+ : searchResultsObj;
+
+ //console.log("sssss", searchResultsObj);
+
+ loggedInUser = loggedInUser.value[0].contactid;
+
+ const watchedCases = await getWatchedCases(loggedInUser);
+
+ console.log("sssss", loggedInUser);
+
+ const [accountDetails, searchDetailsObj, watchedCasesDetails] =
+ await Promise.all([
+ await getPersonalAccount(loggedInUser),
+ await getSearchDetails(searchResultsObj),
+ await getDetails(watchedCases, "myWatchedCases"),
+ ]);
+ store.dispatch(setAccountDetails(accountDetails));
+ store.dispatch(setSearchResults(searchResultsObj));
+ store.dispatch(setSearchDetails(searchDetailsObj));
+ store.dispatch(setSearch(query.q));
+ store.dispatch(setWatchedCases(watchedCases));
+ store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
+ store.dispatch(setLoggedInUserId(loggedInUser));
+
+ thisSession != false &&
+ store.dispatch(setContainerID(thisSession.user.id));
+ }
}
);
diff --git a/pages/myportal/viewall.js b/pages/myportal/viewall.js
index 51064cb3..bcf2da58 100644
--- a/pages/myportal/viewall.js
+++ b/pages/myportal/viewall.js
@@ -8,6 +8,7 @@ import Footer from "../../components/footer";
import Header from "../../components/header";
import ViewAll from "../../components/myportal/viewall";
import TimeOut from "../../components/timeout";
+import { getSession, useSession } from "next-auth/react";
const Home = (props) => {
const { footerLinks, pages } = props;
@@ -17,6 +18,17 @@ const Home = (props) => {
const { locale } = router;
const { appealtypes } = router.query;
+ const { data: session, status } = useSession();
+
+ if (status === "loading") {
+ return
;
+ }
+
+ if (status === "unauthenticated") {
+ router.push("/auth/signin");
+ return
;
+ }
+
return (
diff --git a/pages/newappeal/[appealtypes].js b/pages/newappeal/[appealtypes].js
index 925516f2..ed383ef3 100644
--- a/pages/newappeal/[appealtypes].js
+++ b/pages/newappeal/[appealtypes].js
@@ -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;
diff --git a/pages/newappeal/aboutyou.js b/pages/newappeal/aboutyou.js
index 4cf9c7f4..dbf82807 100644
--- a/pages/newappeal/aboutyou.js
+++ b/pages/newappeal/aboutyou.js
@@ -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,
+ },
+ };
+ }
}
);
diff --git a/pages/newappeal/index.js b/pages/newappeal/index.js
index eb2c00a8..b736cbc4 100644
--- a/pages/newappeal/index.js
+++ b/pages/newappeal/index.js
@@ -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 },
- };
}
);