Merged PR 2315: Auth stabilistatiion and hardening
Related work items: #23020
This commit is contained in:
@@ -14,35 +14,41 @@ import { PrismaAdapter } from "@next-auth/prisma-adapter";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import NextAuth from "next-auth";
|
||||
import EmailProvider from "next-auth/providers/email";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import { consoleLogger, redactSensitive } from "../../../actions/core/logger";
|
||||
import { getPortalLogin } from "../../../actions/services/accountService";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const WELSH_LANGUAGE_CODE = 846040000;
|
||||
|
||||
const appendParamsAndPathToNewUrl = (fromUrl, toUrl) => {
|
||||
const fromUrlObj = new URL(fromUrl);
|
||||
const params = fromUrlObj.searchParams;
|
||||
|
||||
const toUrlObj = new URL(toUrl);
|
||||
toUrlObj.pathname = fromUrlObj.pathname;
|
||||
|
||||
params.forEach((value, key) => {
|
||||
if (!toUrlObj.searchParams.has(key)) {
|
||||
toUrlObj.searchParams.append(key, value);
|
||||
}
|
||||
});
|
||||
|
||||
return toUrlObj.toString();
|
||||
const authDiagnostic = (event, metadata = {}) => {
|
||||
try {
|
||||
const safeMeta = JSON.parse(JSON.stringify(metadata));
|
||||
console.info(`[auth][${event}]`, redactSensitive(safeMeta));
|
||||
} catch (_error) {
|
||||
console.info(`[auth][${event}]`);
|
||||
}
|
||||
};
|
||||
|
||||
// const resolveRequestLocale = (req) => {
|
||||
// const locale =
|
||||
// req?.body?.locale || req?.query?.locale || req?.cookies?.pedw_locale;
|
||||
const appendParamsAndPathToNewUrl = (fromUrl, toUrl) => {
|
||||
try {
|
||||
const fromUrlObj = new URL(fromUrl);
|
||||
const params = fromUrlObj.searchParams;
|
||||
|
||||
// return locale === "cy" ? "cy" : "en";
|
||||
// };
|
||||
const toUrlObj = new URL(toUrl);
|
||||
toUrlObj.pathname = fromUrlObj.pathname;
|
||||
|
||||
params.forEach((value, key) => {
|
||||
if (!toUrlObj.searchParams.has(key)) {
|
||||
toUrlObj.searchParams.append(key, value);
|
||||
}
|
||||
});
|
||||
|
||||
return toUrlObj.toString();
|
||||
} catch (_error) {
|
||||
return toUrl;
|
||||
}
|
||||
};
|
||||
|
||||
const resolveCrmLocale = async (email) => {
|
||||
if (!email) return null;
|
||||
@@ -69,9 +75,20 @@ const resolveCrmLocale = async (email) => {
|
||||
|
||||
const resolveEffectiveLocale = async (req, email) => {
|
||||
const crmLocale = await resolveCrmLocale(email);
|
||||
if (crmLocale) return crmLocale;
|
||||
if (crmLocale) {
|
||||
authDiagnostic("effective-locale.crm", {
|
||||
locale: crmLocale,
|
||||
hasEmail: !!email
|
||||
});
|
||||
return crmLocale;
|
||||
}
|
||||
|
||||
return resolveRequestLocale(req);
|
||||
const requestLocale = resolveRequestLocale(req);
|
||||
authDiagnostic("effective-locale.request", {
|
||||
locale: requestLocale,
|
||||
hasEmail: !!email
|
||||
});
|
||||
return requestLocale;
|
||||
};
|
||||
|
||||
const buildLocalizedVerificationUrl = ({ url, email, effectiveLocale }) => {
|
||||
@@ -117,19 +134,35 @@ const getLocaleFromCallbackUrl = (callbackUrl) => {
|
||||
|
||||
const resolveRequestLocale = (req) => {
|
||||
const directLocale =
|
||||
req?.body?.locale || req?.query?.locale || req?.cookies?.pedw_locale;
|
||||
req?.query?.locale || req?.body?.locale || req?.cookies?.pedw_locale;
|
||||
|
||||
if (directLocale === "cy") return "cy";
|
||||
if (directLocale === "en") return "en";
|
||||
if (directLocale === "cy") {
|
||||
authDiagnostic("request-locale.direct", { locale: "cy" });
|
||||
return "cy";
|
||||
}
|
||||
if (directLocale === "en") {
|
||||
authDiagnostic("request-locale.direct", { locale: "en" });
|
||||
return "en";
|
||||
}
|
||||
|
||||
const callbackLocale =
|
||||
getLocaleFromCallbackUrl(req?.body?.callbackUrl) ||
|
||||
getLocaleFromCallbackUrl(req?.query?.callbackUrl) ||
|
||||
getLocaleFromCallbackUrl(req?.cookies?.["next-auth.callback-url"]) ||
|
||||
getLocaleFromCallbackUrl(
|
||||
req?.cookies?.["__Secure-next-auth.callback-url"]
|
||||
);
|
||||
|
||||
return callbackLocale === "cy" ? "cy" : "en";
|
||||
const resolved = callbackLocale === "cy" ? "cy" : "en";
|
||||
authDiagnostic("request-locale.callback-fallback", {
|
||||
locale: resolved,
|
||||
hasBodyCallback: !!req?.body?.callbackUrl,
|
||||
hasQueryCallback: !!req?.query?.callbackUrl,
|
||||
hasLegacyCookieCallback: !!req?.cookies?.["next-auth.callback-url"],
|
||||
hasSecureCookieCallback:
|
||||
!!req?.cookies?.["__Secure-next-auth.callback-url"]
|
||||
});
|
||||
return resolved;
|
||||
};
|
||||
|
||||
const authOptions = (req, res) => {
|
||||
@@ -147,24 +180,12 @@ const authOptions = (req, res) => {
|
||||
email
|
||||
);
|
||||
|
||||
console.log(
|
||||
"============================================================\n",
|
||||
"verification url API: " + url + "\n",
|
||||
"============================================================\n"
|
||||
);
|
||||
|
||||
const formURL = buildLocalizedVerificationUrl({
|
||||
url,
|
||||
email,
|
||||
effectiveLocale
|
||||
});
|
||||
|
||||
console.log(
|
||||
"============================================================\n",
|
||||
"new verification url----: " + formURL + "\n",
|
||||
"============================================================\n"
|
||||
);
|
||||
|
||||
return res
|
||||
.writeHead(200, { "Content-Type": "application/json" })
|
||||
.json({ url: formURL });
|
||||
@@ -181,24 +202,12 @@ const authOptions = (req, res) => {
|
||||
email
|
||||
);
|
||||
|
||||
console.log(
|
||||
"============================================================\n",
|
||||
"verification url----: " + url + "\n",
|
||||
"============================================================\n"
|
||||
);
|
||||
|
||||
const formURL = buildLocalizedVerificationUrl({
|
||||
url,
|
||||
email,
|
||||
effectiveLocale
|
||||
});
|
||||
|
||||
console.log(
|
||||
"============================================================\n",
|
||||
"new verification url----: " + formURL + "\n",
|
||||
"============================================================\n"
|
||||
);
|
||||
|
||||
const personalisation = {
|
||||
emailAddress: email,
|
||||
signInLink: formURL,
|
||||
@@ -261,15 +270,21 @@ const authOptions = (req, res) => {
|
||||
},
|
||||
callbacks: {
|
||||
session: async (session, user) => {
|
||||
console.log("callback in auth", session, user);
|
||||
return Promise.resolve(session);
|
||||
},
|
||||
|
||||
redirect({ url, baseUrl }) {
|
||||
console.log("baseurl:", url, baseUrl);
|
||||
|
||||
if (url.startsWith("/")) return `${baseUrl}${url}`;
|
||||
if (new URL(url).origin === baseUrl) return url;
|
||||
|
||||
try {
|
||||
if (new URL(url).origin === baseUrl) return url;
|
||||
} catch (_error) {
|
||||
authDiagnostic("redirect.invalid-url", {
|
||||
baseUrl,
|
||||
hasUrl: !!url
|
||||
});
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
const newUrl =
|
||||
requestLocale === "cy"
|
||||
@@ -277,7 +292,10 @@ const authOptions = (req, res) => {
|
||||
: process.env.NEXTAUTH_URL;
|
||||
|
||||
const updatedUrl = appendParamsAndPathToNewUrl(url, newUrl);
|
||||
console.log(updatedUrl);
|
||||
authDiagnostic("redirect.external-rewrite", {
|
||||
locale: requestLocale,
|
||||
targetOrigin: newUrl
|
||||
});
|
||||
return updatedUrl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,10 +156,10 @@ export default async function ApiProxy(req, res) {
|
||||
queryUrl =
|
||||
"pinswg_sipses?$count=true&$expand=pinswg_sipscase&$filter=_pinswg_projecttype_value eq " +
|
||||
searchString.projecttype +
|
||||
(searchString.hasOwnProperty("q")
|
||||
(Object.prototype.hasOwnProperty.call(searchString, "q")
|
||||
? " and contains(pinswg_projectname, '" + searchString.q + "')"
|
||||
: "") +
|
||||
(searchString.hasOwnProperty("lpa")
|
||||
(Object.prototype.hasOwnProperty.call(searchString, "lpa")
|
||||
? " and _pinswg_associatedlpa_value eq " +
|
||||
searchString.lpa +
|
||||
" "
|
||||
|
||||
@@ -162,7 +162,7 @@ export default async function ApiProxy(req, res) {
|
||||
"@odata.count": coordsObj["@odata.count"]
|
||||
};
|
||||
|
||||
return req.query.hasOwnProperty("fordmw")
|
||||
return Object.prototype.hasOwnProperty.call(req.query, "fordmw")
|
||||
? respondSuccess(res, updatedData)
|
||||
: respondSuccess(res, coordsObj);
|
||||
} catch (error) {
|
||||
|
||||
@@ -136,7 +136,10 @@ export default async function handler(req, res) {
|
||||
return blobList;
|
||||
};
|
||||
|
||||
reqBodyobj = reqBodyobj?.hasOwnProperty("filesList")
|
||||
reqBodyobj = Object.prototype.hasOwnProperty.call(
|
||||
reqBodyobj || {},
|
||||
"filesList"
|
||||
)
|
||||
? cleanFilesList(reqBodyobj)
|
||||
: reqBodyobj;
|
||||
|
||||
|
||||
+4
-8
@@ -7,10 +7,10 @@ import CookieBanner from "../../components/cookieBanner";
|
||||
import Footer from "../../components/footer";
|
||||
import Header from "../../components/header";
|
||||
import ServiceBanner from "../../components/servicebanner";
|
||||
import { destroyCookie, setCookie } from "nookies";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { getCsrfToken } from "next-auth/react";
|
||||
import { clearSessionArtifacts } from "../../lib/auth/sessionClient";
|
||||
|
||||
const Error = (props) => {
|
||||
let { t, lang } = useTranslation();
|
||||
@@ -19,11 +19,7 @@ const Error = (props) => {
|
||||
const { error } = useRouter().query;
|
||||
|
||||
useEffect(() => {
|
||||
window.localStorage.clear(),
|
||||
destroyCookie(null, "next-auth.csrf-token", { path: "/" }),
|
||||
destroyCookie(null, "next-auth.callback-url", { path: "/" }),
|
||||
destroyCookie(null, "pedw_locale", { path: "/" }),
|
||||
destroyCookie(null, "pinsUser", { path: "/" });
|
||||
clearSessionArtifacts();
|
||||
}, []);
|
||||
|
||||
const errors = {
|
||||
@@ -37,7 +33,7 @@ const Error = (props) => {
|
||||
EmailSignin: t("auth:auth-error-EmailSignin-label"),
|
||||
CredentialsSignin: t("auth:auth-error-CredentialsSignin-label"),
|
||||
Verification: t("auth:auth-error-Verification-label"),
|
||||
default: t("auth:auth-error-default-label"),
|
||||
default: t("auth:auth-error-default-label")
|
||||
};
|
||||
|
||||
const errorMessage = error && (errors[error] ?? errors.default);
|
||||
@@ -89,7 +85,7 @@ const Error = (props) => {
|
||||
export async function getServerSideProps(context) {
|
||||
const csrfToken = await getCsrfToken(context);
|
||||
return {
|
||||
props: { csrfToken },
|
||||
props: { csrfToken }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -141,9 +141,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
if (thisSession) {
|
||||
console.log(" has sesssion.......");
|
||||
[loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email)
|
||||
]);
|
||||
loggedInUser = await getPortalLogin(thisSession.user.email);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
|
||||
|
||||
@@ -112,9 +112,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
if (thisSession) {
|
||||
console.log(" has sesssion.......");
|
||||
[loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email)
|
||||
]);
|
||||
loggedInUser = await getPortalLogin(thisSession.user.email);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
|
||||
@@ -163,7 +161,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
: "pinswg_siteaddressline1";
|
||||
|
||||
store.dispatch(
|
||||
req.headers.hasOwnProperty("referer")
|
||||
Object.prototype.hasOwnProperty.call(req.headers, "referer")
|
||||
? req.headers.referer.indexOf("?") > -1
|
||||
? setSearch(req.headers.referer.split("?")[1])
|
||||
: setSearch(
|
||||
|
||||
+9
-3
@@ -141,7 +141,10 @@ const RenderMultiline = ({
|
||||
className={className}
|
||||
{...input}
|
||||
maxLength={
|
||||
custom.hasOwnProperty("maxFieldLength")
|
||||
Object.prototype.hasOwnProperty.call(
|
||||
custom,
|
||||
"maxFieldLength"
|
||||
)
|
||||
? custom.maxFieldLength
|
||||
? custom.maxFieldLength
|
||||
: 800
|
||||
@@ -190,14 +193,17 @@ const RenderTextfield = ({
|
||||
name={id || name}
|
||||
id={id || name}
|
||||
maxLength={
|
||||
custom.hasOwnProperty("maxFieldLength")
|
||||
Object.prototype.hasOwnProperty.call(
|
||||
custom,
|
||||
"maxFieldLength"
|
||||
)
|
||||
? custom.maxFieldLength
|
||||
? custom.maxFieldLength
|
||||
: 100
|
||||
: 200
|
||||
}
|
||||
pattern={
|
||||
custom.hasOwnProperty("pattern")
|
||||
Object.prototype.hasOwnProperty.call(custom, "pattern")
|
||||
? custom.pattern
|
||||
: undefined
|
||||
}
|
||||
|
||||
@@ -144,9 +144,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
if (thisSession) {
|
||||
console.log(" has sesssion.......");
|
||||
[loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email)
|
||||
]);
|
||||
loggedInUser = await getPortalLogin(thisSession.user.email);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
|
||||
|
||||
@@ -3,23 +3,19 @@ import { signOut } from "next-auth/react";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import Link from "next/link";
|
||||
import { destroyCookie } from "nookies";
|
||||
import { useRouter } from "next/router";
|
||||
import CookieBanner from "../components/cookieBanner";
|
||||
import Footer from "../components/footer";
|
||||
import Header from "../components/header";
|
||||
import { performPortalSignOut } from "../lib/auth/sessionClient";
|
||||
|
||||
const FourOhFour = (props) => {
|
||||
let { t, lang } = useTranslation();
|
||||
const { footerLinks, pages } = props;
|
||||
const { locale } = useRouter();
|
||||
|
||||
const handleLogout = () => {
|
||||
console.info("////////////\n" + "logout" + "\n////////////");
|
||||
window.localStorage.clear(),
|
||||
destroyCookie(null, "next-auth.csrf-token", { path: "/" }),
|
||||
destroyCookie(null, "next-auth.callback-url", { path: "/" }),
|
||||
destroyCookie(null, "pedw_locale", { path: "/" }),
|
||||
destroyCookie(null, "pinsUser", { path: "/" }),
|
||||
signOut({ callbackUrl: "/" });
|
||||
performPortalSignOut({ locale, callbackUrl: "/", signOutFn: signOut });
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -140,7 +140,7 @@ const Home = (props) => {
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
const { query, req } = ctx;
|
||||
getIP(req);
|
||||
const searchResultsObj = await getAddressSearch(query);
|
||||
const searchDetailsObj = searchResultsObj;
|
||||
@@ -168,14 +168,14 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
const [accountDetails, searchResultsObj, watchedCases] =
|
||||
await Promise.all([
|
||||
await getPersonalAccount(loggedInUser),
|
||||
await getAdvancedSearch(query),
|
||||
await getWatchedCases(loggedInUser)
|
||||
getPersonalAccount(loggedInUser),
|
||||
getAdvancedSearch(query),
|
||||
getWatchedCases(loggedInUser)
|
||||
]);
|
||||
|
||||
const [searchDetailsObj, watchedCasesDetails] = await Promise.all([
|
||||
await getSearchDetails(searchResultsObj),
|
||||
await getDetails(watchedCases, "myWatchedCases")
|
||||
getSearchDetails(searchResultsObj),
|
||||
getDetails(watchedCases, "myWatchedCases")
|
||||
]);
|
||||
|
||||
store.dispatch(setAccountDetails(accountDetails));
|
||||
@@ -203,7 +203,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const getDetails = (resultsObj, detailsType) => {
|
||||
let detailsArr = [];
|
||||
resultsObj = resultsObj.value;
|
||||
const detailsObj = resultsObj.map((searchDetail, index) => {
|
||||
const detailsObj = resultsObj.map((searchDetail) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(
|
||||
detailsType != "myWatchedCases"
|
||||
|
||||
@@ -2,7 +2,7 @@ import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import { getIP } from "../../actions/core/logger";
|
||||
import { consoleLogger, getIP } from "../../actions/core/logger";
|
||||
import {
|
||||
getPersonalAccount,
|
||||
getPortalLogin
|
||||
@@ -46,7 +46,6 @@ const Home = (props) => {
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { appealtypes } = router.query;
|
||||
|
||||
return (
|
||||
@@ -79,44 +78,98 @@ const Home = (props) => {
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
const { query, req } = ctx;
|
||||
getIP(req);
|
||||
console.log("query-", query);
|
||||
//console.log("search array:", Object.entries(query));
|
||||
const { cookies } = req;
|
||||
|
||||
const showLoginCheck = process.env.SHOWLOGIN || false;
|
||||
|
||||
let thisSession = await getSession(ctx);
|
||||
|
||||
let loggedInUser = await getPortalLogin(thisSession.user.email);
|
||||
|
||||
if (!thisSession) {
|
||||
console.log("not has sesssion.......");
|
||||
consoleLogger({
|
||||
name: "MyPortalAdvancedSearchResultsAuthGuard",
|
||||
reasonCode: "NO_SESSION",
|
||||
message:
|
||||
"advancedsearchresults loader missing session; redirecting to signin"
|
||||
});
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/auth/signin",
|
||||
permanent: false
|
||||
}
|
||||
};
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!thisSession?.user?.email || !thisSession?.user?.id) {
|
||||
consoleLogger({
|
||||
name: "MyPortalAdvancedSearchResultsAuthGuard",
|
||||
reasonCode: "NO_SESSION_USER",
|
||||
message:
|
||||
"advancedsearchresults loader missing session user identity; redirecting to signin",
|
||||
hasSessionUserEmail: !!thisSession?.user?.email,
|
||||
hasSessionUserId: !!thisSession?.user?.id
|
||||
});
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/auth/signin",
|
||||
permanent: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let loggedInUser;
|
||||
try {
|
||||
const loggedInUserLookup = await getPortalLogin(
|
||||
thisSession.user.email
|
||||
);
|
||||
loggedInUser = loggedInUserLookup?.value?.[0]?.contactid;
|
||||
} catch (error) {
|
||||
consoleLogger({
|
||||
name: "MyPortalAdvancedSearchResultsAuthGuard",
|
||||
reasonCode: "UPSTREAM_FAILURE",
|
||||
message:
|
||||
"advancedsearchresults loader portal login lookup failed; redirecting to signin",
|
||||
error: error?.message
|
||||
});
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/auth/signin",
|
||||
permanent: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (!loggedInUser) {
|
||||
consoleLogger({
|
||||
name: "MyPortalAdvancedSearchResultsAuthGuard",
|
||||
reasonCode: "CONTACT_LOOKUP_FAILED",
|
||||
message:
|
||||
"advancedsearchresults loader missing CRM contact id; redirecting to signin"
|
||||
});
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/auth/signin",
|
||||
permanent: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
thisSession != false &&
|
||||
store.dispatch(setContainerID(thisSession.user.id));
|
||||
|
||||
loggedInUser = await getPortalLogin(thisSession.user.email);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
|
||||
const [accountDetails, watchedCases] = await Promise.all([
|
||||
await getPersonalAccount(loggedInUser),
|
||||
await getWatchedCases(loggedInUser)
|
||||
getPersonalAccount(loggedInUser),
|
||||
getWatchedCases(loggedInUser)
|
||||
]);
|
||||
|
||||
console.log(accountDetails);
|
||||
|
||||
const [watchedCasesDetails] = await Promise.all([
|
||||
await getDetails(watchedCases, "myWatchedCases")
|
||||
]);
|
||||
const watchedCasesDetails = await getDetails(
|
||||
watchedCases,
|
||||
"myWatchedCases"
|
||||
);
|
||||
|
||||
const showLoginCheck = process.env.SHOWLOGIN || false;
|
||||
const showReps = process.env.SHOWREPRESENTATIONS || false;
|
||||
@@ -127,7 +180,22 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
||||
store.dispatch(setSearch(Object.entries(query)));
|
||||
store.dispatch(setLoggedInUserId(loggedInUser));
|
||||
} catch (error) {
|
||||
consoleLogger({
|
||||
name: "MyPortalAdvancedSearchResultsAuthGuard",
|
||||
reasonCode: "UPSTREAM_FAILURE",
|
||||
message:
|
||||
"advancedsearchresults loader dependency failure; redirecting to signin",
|
||||
error: error?.message
|
||||
});
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/auth/signin",
|
||||
permanent: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
showLoginCheck: showLoginCheck
|
||||
@@ -139,7 +207,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const getDetails = (resultsObj, detailsType) => {
|
||||
let detailsArr = [];
|
||||
resultsObj = resultsObj.value;
|
||||
const detailsObj = resultsObj.map((searchDetail, index) => {
|
||||
const detailsObj = resultsObj.map((searchDetail) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(
|
||||
detailsType != "myWatchedCases"
|
||||
|
||||
@@ -2,7 +2,7 @@ import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import { getIP } from "../../../actions/core/logger";
|
||||
import { consoleLogger, getIP } from "../../../actions/core/logger";
|
||||
import {
|
||||
getPersonalAccount,
|
||||
getPortalLogin
|
||||
@@ -61,17 +61,10 @@ import ServiceBanner from "../../../components/myportal/servicebanner";
|
||||
import TimeOut from "../../../components/timeout";
|
||||
|
||||
const CaseHome = (props) => {
|
||||
const {
|
||||
footerLinks,
|
||||
pages,
|
||||
setSearchResults,
|
||||
setSearchDetails,
|
||||
searchResultsObj
|
||||
} = props;
|
||||
let { t, lang } = useTranslation();
|
||||
const { footerLinks } = props;
|
||||
useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { ticketnumber } = router.query;
|
||||
|
||||
return (
|
||||
@@ -94,9 +87,6 @@ const CaseHome = (props) => {
|
||||
props={props}
|
||||
myCases={props.myCases.myCases}
|
||||
myCasesDetails={props.myCases.myCasesDetails}
|
||||
// directSearchResultsObj={
|
||||
// props.searchResultsObj.searchResultsObj
|
||||
// }
|
||||
searchResultsObj={
|
||||
props.searchResultsObj.searchResultsObj
|
||||
}
|
||||
@@ -150,28 +140,44 @@ const CaseHome = (props) => {
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
const { query, req } = ctx;
|
||||
getIP(req);
|
||||
const { cookies } = req;
|
||||
|
||||
console.log(cookies);
|
||||
console.log("the query :", query.ticketnumber);
|
||||
|
||||
console.log("viewkey: " + (query.hasOwnProperty("key") ? "yes" : "no"));
|
||||
consoleLogger({
|
||||
name: "MyPortalCaseTicketLoaderStart",
|
||||
message: "myportal case ticket loader invoked",
|
||||
hasTicketNumber: !!query?.ticketnumber,
|
||||
hasViewKey: Object.prototype.hasOwnProperty.call(query, "key")
|
||||
});
|
||||
|
||||
const showLoginCheck = process.env.SHOWLOGIN || false;
|
||||
let thisSession = await getSession(ctx);
|
||||
const thisSession = await getSession(ctx);
|
||||
let loggedInUser = {};
|
||||
|
||||
if (thisSession) {
|
||||
console.log(" has sesssion.......");
|
||||
[loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email)
|
||||
]);
|
||||
loggedInUser = await getPortalLogin(thisSession.user.email);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
loggedInUser = loggedInUser?.value?.[0]?.contactid;
|
||||
if (!loggedInUser) {
|
||||
consoleLogger({
|
||||
name: "MyPortalCaseTicketMissingContact",
|
||||
message:
|
||||
"myportal case ticket loader missing CRM contact id; redirecting to signin",
|
||||
hasSessionEmail: !!thisSession?.user?.email
|
||||
});
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/auth/signin",
|
||||
permanent: false
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
console.log("not has sesssion.......");
|
||||
consoleLogger({
|
||||
name: "MyPortalCaseTicketMissingSession",
|
||||
message:
|
||||
"myportal case ticket loader missing session; redirecting to signin"
|
||||
});
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/auth/signin",
|
||||
@@ -191,22 +197,24 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
store.dispatch(setAccountDetails(accountDetails));
|
||||
store.dispatch(setLoggedInUserId(loggedInUser));
|
||||
|
||||
let developmentQuery = query.ticketnumber;
|
||||
const developmentQuery = query.ticketnumber;
|
||||
|
||||
const pattern = /CAS-\d{5}-[A-Z0-9]{6}/;
|
||||
const match = query.ticketnumber.match(pattern);
|
||||
|
||||
if (match) {
|
||||
console.log("Match found!", match[0]);
|
||||
} else {
|
||||
console.log("No match.");
|
||||
if (!match) {
|
||||
consoleLogger({
|
||||
name: "MyPortalCaseTicketUnexpectedFormat",
|
||||
message: "ticketnumber does not match CAS expected format",
|
||||
hasTicketNumber: !!query?.ticketnumber
|
||||
});
|
||||
}
|
||||
|
||||
const searchResultsObj = await getBasicSearch(developmentQuery);
|
||||
const searchDetailsObj = await getSearchDetails(searchResultsObj);
|
||||
|
||||
var eventsObj = {};
|
||||
var mediaObj = {};
|
||||
let eventsObj = {};
|
||||
let mediaObj = {};
|
||||
|
||||
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
||||
eventsObj = await getSIPSEvents(
|
||||
@@ -220,25 +228,16 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
store.dispatch(setMediaDetails(mediaObj));
|
||||
}
|
||||
//console.log(
|
||||
// "\n======================================\n",
|
||||
// searchResultsObj,
|
||||
// "\n======================================\n"
|
||||
// );
|
||||
//console.log(
|
||||
// "\n======================================\n",
|
||||
// searchDetailsObj[0],
|
||||
// "\n======================================\n"
|
||||
// );
|
||||
|
||||
store.dispatch(setSearch(developmentQuery));
|
||||
|
||||
// console.log(
|
||||
// searchResultsObj["@odata.count"] > 1 ||
|
||||
// searchResultsObj["@odata.count"] < 1
|
||||
// );
|
||||
|
||||
if (searchResultsObj["@odata.count"] < 1) {
|
||||
consoleLogger({
|
||||
name: "MyPortalCaseTicketSearchNotFound",
|
||||
message:
|
||||
"myportal case ticket loader search count < 1; redirecting to 404",
|
||||
ticketnumber: query?.ticketnumber
|
||||
});
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/404",
|
||||
@@ -247,6 +246,13 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
};
|
||||
} else {
|
||||
if (searchResultsObj["@odata.count"] > 1) {
|
||||
consoleLogger({
|
||||
name: "MyPortalCaseTicketSearchAmbiguous",
|
||||
message:
|
||||
"myportal case ticket loader search count > 1; redirecting to 404",
|
||||
ticketnumber: query?.ticketnumber,
|
||||
count: searchResultsObj["@odata.count"]
|
||||
});
|
||||
return {
|
||||
redirect: {
|
||||
//destination: "/dns-not-found",
|
||||
@@ -255,7 +261,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
}
|
||||
};
|
||||
} else {
|
||||
if (query.hasOwnProperty("key")) {
|
||||
if (Object.prototype.hasOwnProperty.call(query, "key")) {
|
||||
let whichViewKey = query.key;
|
||||
|
||||
switch (whichViewKey) {
|
||||
@@ -268,42 +274,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
);
|
||||
break;
|
||||
case "watchedCases":
|
||||
// const watchedCases = await getWatchedCases(
|
||||
// loggedInUser
|
||||
// );
|
||||
|
||||
// let showWatchedCases = (submittedArr) => {
|
||||
// const required = submittedArr.value.filter(
|
||||
// (el) => {
|
||||
// return (
|
||||
// el.pinswg_representationsubmitted ==
|
||||
// null
|
||||
// );
|
||||
// }
|
||||
// );
|
||||
|
||||
// let newObj = {};
|
||||
// return Object.assign(newObj, {
|
||||
// "@odata.count": required.length,
|
||||
// "value": required,
|
||||
// });
|
||||
// };
|
||||
|
||||
// let filteredWatchedCases =
|
||||
// showWatchedCases(watchedCases);
|
||||
|
||||
// const watchedCasesDetails = await getDetails(
|
||||
// filteredWatchedCases,
|
||||
// "myWatchedCases"
|
||||
// );
|
||||
|
||||
// store.dispatch(
|
||||
// setWatchedCases(filteredWatchedCases)
|
||||
// );
|
||||
// store.dispatch(
|
||||
// setWatchedCasesDetails(watchedCasesDetails)
|
||||
// );
|
||||
|
||||
store.dispatch(
|
||||
setCurrentView({
|
||||
"viewName": "Watched Cases",
|
||||
@@ -362,19 +332,19 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
}
|
||||
const watchedCases = await getWatchedCases(loggedInUser);
|
||||
|
||||
let showWatchedCases = (submittedArr) => {
|
||||
const showWatchedCases = (submittedArr) => {
|
||||
const required = submittedArr.value.filter((el) => {
|
||||
return el.pinswg_representationsubmitted == null;
|
||||
});
|
||||
|
||||
let newObj = {};
|
||||
const newObj = {};
|
||||
return Object.assign(newObj, {
|
||||
"@odata.count": required.length,
|
||||
"value": required
|
||||
});
|
||||
};
|
||||
|
||||
let filteredWatchedCases = showWatchedCases(watchedCases);
|
||||
const filteredWatchedCases = showWatchedCases(watchedCases);
|
||||
|
||||
const watchedCasesDetails = await getDetails(
|
||||
filteredWatchedCases,
|
||||
@@ -415,9 +385,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(el) => el.pinswg_representationsubmitted != null
|
||||
);
|
||||
|
||||
const [mySubmittedRepsDetails] = await Promise.all([
|
||||
getDetails(mySubmittedReps, "mySubmittedReps")
|
||||
]);
|
||||
const mySubmittedRepsDetails = await getDetails(
|
||||
mySubmittedReps,
|
||||
"mySubmittedReps"
|
||||
);
|
||||
|
||||
store.dispatch(setMySubmittedReps(mySubmittedReps));
|
||||
store.dispatch(
|
||||
@@ -425,9 +396,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
);
|
||||
}
|
||||
}
|
||||
//console.log(searchResultsObj);
|
||||
|
||||
//console.log(loggedInUser);
|
||||
return {
|
||||
props: {
|
||||
searchResultsObj: {
|
||||
@@ -455,7 +423,7 @@ const getDetails = (resultsObj, detailsType) => {
|
||||
detailsType == "mySubmittedReps" ? resultsObj : resultsObj.value;
|
||||
|
||||
if (detailsType == "myRepresentations") {
|
||||
const repsObj = resultsObj.map((searchDetail, index) => {
|
||||
resultsObj.map((searchDetail) => {
|
||||
detailsArr.push(
|
||||
getCase(searchDetail["incidentID"]).then((data) => {
|
||||
let caseID = "";
|
||||
@@ -488,7 +456,7 @@ const getDetails = (resultsObj, detailsType) => {
|
||||
});
|
||||
}
|
||||
|
||||
const detailsObj = resultsObj.map((searchDetail, index) => {
|
||||
resultsObj.map((searchDetail) => {
|
||||
let caseID = "";
|
||||
|
||||
switch (detailsType) {
|
||||
@@ -512,25 +480,17 @@ const getDetails = (resultsObj, detailsType) => {
|
||||
caseID = searchDetail.pinswg_title;
|
||||
}
|
||||
|
||||
//console.log(detailsType, " case id : ", caseID);
|
||||
|
||||
searchDetail.pinswg_appealcasetype != null &&
|
||||
detailsArr.push(
|
||||
getPortalModuleDetails(
|
||||
getFormCollectionByID(searchDetail.pinswg_appealcasetype)
|
||||
.LogicalCollectionName,
|
||||
caseID
|
||||
// detailsType != "myWatchedCases"
|
||||
// ? searchDetail.ticketnumber
|
||||
// : searchDetail[
|
||||
// "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
// ]
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
let detArr = Promise.all(detailsArr);
|
||||
console.log(detArr);
|
||||
const detArr = Promise.all(detailsArr);
|
||||
return detArr;
|
||||
};
|
||||
|
||||
@@ -539,7 +499,6 @@ const mapStateToProps = (state) => {
|
||||
accountDetails: state.accountDetails,
|
||||
currentView: state.currentView,
|
||||
search: state.search,
|
||||
//searchResultsObj: state.searchResultsObj,
|
||||
documentDetailsObj: state.searchResultsObj.documentDetailsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
@@ -557,12 +516,6 @@ const mapDispatchToProps = (dispatch) => {
|
||||
setCurrentReference: (currentReference) => {
|
||||
dispatch(setCurrentReference(refno));
|
||||
},
|
||||
// setSearchResults: (searchResults) => {
|
||||
// dispatch(setSearchResults(searchResults));
|
||||
// },
|
||||
// setSearchDetails: (searchDetails) => {
|
||||
// dispatch(setSearchDetails(searchDetails));
|
||||
// },
|
||||
setLoggedInUserId: (loggedInUser) => {
|
||||
dispatch(setLoggedInUserId(loggedInUser));
|
||||
}
|
||||
|
||||
@@ -111,9 +111,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
if (thisSession) {
|
||||
console.log(" has sesssion.......");
|
||||
[loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email)
|
||||
]);
|
||||
loggedInUser = await getPortalLogin(thisSession.user.email);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
|
||||
|
||||
@@ -141,7 +141,10 @@ const RenderMultiline = ({
|
||||
className={className}
|
||||
{...input}
|
||||
maxLength={
|
||||
custom.hasOwnProperty("maxFieldLength")
|
||||
Object.prototype.hasOwnProperty.call(
|
||||
custom,
|
||||
"maxFieldLength"
|
||||
)
|
||||
? custom.maxFieldLength
|
||||
? custom.maxFieldLength
|
||||
: 800
|
||||
@@ -190,14 +193,17 @@ const RenderTextfield = ({
|
||||
name={id || name}
|
||||
id={id || name}
|
||||
maxLength={
|
||||
custom.hasOwnProperty("maxFieldLength")
|
||||
Object.prototype.hasOwnProperty.call(
|
||||
custom,
|
||||
"maxFieldLength"
|
||||
)
|
||||
? custom.maxFieldLength
|
||||
? custom.maxFieldLength
|
||||
: 100
|
||||
: 200
|
||||
}
|
||||
pattern={
|
||||
custom.hasOwnProperty("pattern")
|
||||
Object.prototype.hasOwnProperty.call(custom, "pattern")
|
||||
? custom.pattern
|
||||
: undefined
|
||||
}
|
||||
|
||||
@@ -142,9 +142,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
if (thisSession) {
|
||||
console.log(" has sesssion.......");
|
||||
[loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email)
|
||||
]);
|
||||
loggedInUser = await getPortalLogin(thisSession.user.email);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ const Home = (props) => {
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { appealtypes } = router.query;
|
||||
|
||||
return (
|
||||
@@ -142,14 +141,12 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
getIP(req);
|
||||
console.log("query-", query);
|
||||
|
||||
const { cookies } = req;
|
||||
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
"public, s-maxage=10, stale-while-revalidate=59"
|
||||
);
|
||||
|
||||
let loggedInUser = cookies.pinsUser;
|
||||
let loggedInUser = req.cookies.pinsUser;
|
||||
|
||||
let thisSession = await getSession(ctx);
|
||||
|
||||
@@ -163,8 +160,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
};
|
||||
} else {
|
||||
let [accountDetails, watchedCases] = await Promise.all([
|
||||
await getPersonalAccount(loggedInUser),
|
||||
await getWatchedCases(loggedInUser)
|
||||
getPersonalAccount(loggedInUser),
|
||||
getWatchedCases(loggedInUser)
|
||||
]);
|
||||
|
||||
// searchResultsObj =
|
||||
@@ -178,9 +175,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
const showMapCheck = process.env.SHOWMAPS || false;
|
||||
|
||||
const [watchedCasesDetails] = await Promise.all([
|
||||
await getDetails(watchedCases, "myWatchedCases")
|
||||
]);
|
||||
const watchedCasesDetails = await getDetails(
|
||||
watchedCases,
|
||||
"myWatchedCases"
|
||||
);
|
||||
const dnsCoords = await getDNSCoords();
|
||||
// store.dispatch(setSearchResults(searchResultsObj));
|
||||
// store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
@@ -201,7 +199,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const getDetails = (resultsObj, detailsType) => {
|
||||
let detailsArr = [];
|
||||
resultsObj = resultsObj.value;
|
||||
const detailsObj = resultsObj.map((searchDetail, index) => {
|
||||
const detailsObj = resultsObj.map((searchDetail) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(
|
||||
detailsType != "myWatchedCases"
|
||||
|
||||
+51
-4
@@ -6,6 +6,7 @@ import { connect } from "react-redux";
|
||||
import pLimit from "p-limit";
|
||||
|
||||
import { getIP } from "../../actions/core/logger";
|
||||
import { consoleLogger } from "../../actions/core/logger";
|
||||
import {
|
||||
getPersonalAccount,
|
||||
getPortalLogin
|
||||
@@ -184,15 +185,49 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const thisSession = await getSession(ctx);
|
||||
|
||||
if (!thisSession) {
|
||||
consoleLogger({
|
||||
name: "MyPortalIndexAuthGuard",
|
||||
reasonCode: "NO_SESSION",
|
||||
message:
|
||||
"myportal index loader missing session; redirecting to signin"
|
||||
});
|
||||
return {
|
||||
redirect: { destination: "/auth/signin", permanent: false }
|
||||
};
|
||||
}
|
||||
|
||||
const loggedInUserResponse = await getPortalLogin(
|
||||
thisSession.user.email
|
||||
);
|
||||
const contacts = loggedInUserResponse?.value || [];
|
||||
if (!thisSession?.user?.email || !thisSession?.user?.id) {
|
||||
consoleLogger({
|
||||
name: "MyPortalIndexAuthGuard",
|
||||
reasonCode: "NO_SESSION_USER",
|
||||
message:
|
||||
"myportal index loader missing session user identity; redirecting to signin",
|
||||
hasSessionUserEmail: !!thisSession?.user?.email,
|
||||
hasSessionUserId: !!thisSession?.user?.id
|
||||
});
|
||||
return {
|
||||
redirect: { destination: "/auth/signin", permanent: false }
|
||||
};
|
||||
}
|
||||
|
||||
let contacts = [];
|
||||
try {
|
||||
const loggedInUserResponse = await getPortalLogin(
|
||||
thisSession.user.email
|
||||
);
|
||||
contacts = loggedInUserResponse?.value || [];
|
||||
} catch (error) {
|
||||
consoleLogger({
|
||||
name: "MyPortalIndexAuthGuard",
|
||||
reasonCode: "UPSTREAM_FAILURE",
|
||||
message:
|
||||
"myportal index loader portal login lookup failed; redirecting to signin",
|
||||
error: error?.message
|
||||
});
|
||||
return {
|
||||
redirect: { destination: "/auth/signin", permanent: false }
|
||||
};
|
||||
}
|
||||
|
||||
if (contacts.length > 1) {
|
||||
return {
|
||||
@@ -208,6 +243,18 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
const loggedInUser = contacts[0]?.contactid;
|
||||
|
||||
if (!loggedInUser) {
|
||||
consoleLogger({
|
||||
name: "MyPortalIndexAuthGuard",
|
||||
reasonCode: "CONTACT_LOOKUP_FAILED",
|
||||
message:
|
||||
"myportal index loader missing CRM contact id; redirecting to signin"
|
||||
});
|
||||
return {
|
||||
redirect: { destination: "/auth/signin", permanent: false }
|
||||
};
|
||||
}
|
||||
|
||||
await createContainerProxy(thisSession.user.id);
|
||||
const accountDetails = await getPersonalAccount(loggedInUser);
|
||||
|
||||
|
||||
@@ -77,14 +77,12 @@ const Home = (props) => {
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
const { query, req } = ctx;
|
||||
getIP(req);
|
||||
console.log("query-", query);
|
||||
|
||||
const { cookies } = req;
|
||||
|
||||
let loggedInUserCookie = cookies.pinsUser;
|
||||
|
||||
let thisSession = await getSession(ctx);
|
||||
|
||||
const showReps = process.env.SHOWREPRESENTATIONS || false;
|
||||
@@ -100,9 +98,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
}
|
||||
};
|
||||
} else {
|
||||
let [loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email)
|
||||
]);
|
||||
let loggedInUser = await getPortalLogin(thisSession.user.email);
|
||||
|
||||
//console.log("sssss", searchResultsObj);
|
||||
|
||||
@@ -113,8 +109,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
//console.log("sssss", loggedInUser);
|
||||
|
||||
const [accountDetails, watchedCasesDetails] = await Promise.all([
|
||||
await getPersonalAccount(loggedInUser),
|
||||
await getDetails(watchedCases, "myWatchedCases")
|
||||
getPersonalAccount(loggedInUser),
|
||||
getDetails(watchedCases, "myWatchedCases")
|
||||
]);
|
||||
store.dispatch(setAccountDetails(accountDetails));
|
||||
store.dispatch(setSearch(query.q));
|
||||
@@ -136,7 +132,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const getDetails = (resultsObj, detailsType) => {
|
||||
let detailsArr = [];
|
||||
resultsObj = resultsObj.value;
|
||||
const detailsObj = resultsObj.map((searchDetail, index) => {
|
||||
const detailsObj = resultsObj.map((searchDetail) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(
|
||||
detailsType != "myWatchedCases"
|
||||
|
||||
@@ -126,7 +126,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
let caseObj = searchResultsObj.value[0] || {};
|
||||
|
||||
let hasUnsubscribed = caseObj.hasOwnProperty("pinswg_watchlistid");
|
||||
let hasUnsubscribed = Object.prototype.hasOwnProperty.call(
|
||||
caseObj,
|
||||
"pinswg_watchlistid"
|
||||
);
|
||||
|
||||
console.log("is there a caseObj", hasUnsubscribed);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user