updated authentication on protected pages

This commit is contained in:
2023-06-05 12:00:28 +01:00
parent 3dd4525770
commit 31375a5999
20 changed files with 408 additions and 119 deletions
+30 -20
View File
@@ -81,29 +81,39 @@ export const getServerSideProps = wrapper.getServerSideProps(
let loggedInUser = cookies.pinsUser;
let thisSession = await getSession(ctx);
thisSession != false &&
store.dispatch(setContainerID(thisSession.user.id));
if (!thisSession) {
console.log("not has sesssion.......");
return {
redirect: {
destination: "/auth/signin",
permanent: false,
},
};
} else {
thisSession != false &&
store.dispatch(setContainerID(thisSession.user.id));
const [accountDetails, searchResultsObj, watchedCases] =
await Promise.all([
await getPersonalAccount(loggedInUser),
await getAdvancedSearch(query),
await getWatchedCases(loggedInUser),
const [accountDetails, searchResultsObj, watchedCases] =
await Promise.all([
await getPersonalAccount(loggedInUser),
await getAdvancedSearch(query),
await getWatchedCases(loggedInUser),
]);
console.log(accountDetails);
const [searchDetailsObj, watchedCasesDetails] = await Promise.all([
await getSearchDetails(searchResultsObj),
await getDetails(watchedCases, "myWatchedCases"),
]);
console.log(accountDetails);
const [searchDetailsObj, watchedCasesDetails] = await Promise.all([
await getSearchDetails(searchResultsObj),
await getDetails(watchedCases, "myWatchedCases"),
]);
store.dispatch(setAccountDetails(accountDetails));
store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(setWatchedCases(watchedCases));
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
store.dispatch(setSearch(Object.entries(query)));
store.dispatch(setAccountDetails(accountDetails));
store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(setWatchedCases(watchedCases));
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
store.dispatch(setSearch(Object.entries(query)));
}
}
);