updated authentication on protected pages
This commit is contained in:
@@ -30,6 +30,8 @@ import {
|
||||
setWatchedCasesDetails,
|
||||
} from "../../store/watchedCases/action";
|
||||
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages, watchedCases, showMap } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
@@ -126,19 +128,30 @@ const Home = (props) => {
|
||||
};
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) =>
|
||||
async ({ query, req, res }) => {
|
||||
console.log("query-", query);
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
console.log("query-", query);
|
||||
|
||||
const { cookies } = req;
|
||||
const { cookies } = req;
|
||||
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
"public, s-maxage=10, stale-while-revalidate=59"
|
||||
);
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
"public, s-maxage=10, stale-while-revalidate=59"
|
||||
);
|
||||
|
||||
let loggedInUser = cookies.pinsUser;
|
||||
let loggedInUser = cookies.pinsUser;
|
||||
|
||||
let thisSession = await getSession(ctx);
|
||||
|
||||
if (!thisSession) {
|
||||
console.log("not has sesssion.......");
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/auth/signin",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
let [searchResultsObj, watchedCases] = await Promise.all([
|
||||
await getBasicDNSSearch(),
|
||||
await getWatchedCases(loggedInUser),
|
||||
@@ -170,6 +183,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
props: { showMap: showMapCheck },
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const getDetails = (resultsObj, detailsType) => {
|
||||
|
||||
Reference in New Issue
Block a user