refactor: migrate myportal index account lookup to server helper

This commit is contained in:
2026-11-06 11:33:49 +00:00
parent 4b552e9cdd
commit bf2e4a3254
2 changed files with 264 additions and 6 deletions
+20 -6
View File
@@ -7,10 +7,8 @@ import pLimit from "p-limit";
import { getIP } from "../../actions/core/logger";
import { consoleLogger } from "../../actions/core/logger";
import {
getPersonalAccount,
getPortalLogin
} from "../../actions/services/accountService";
import { getPortalLogin } from "../../actions/services/accountService";
import { getCrmPersonalAccount } from "../../lib/server/getCrmPersonalAccount";
import {
getCase,
getPortalModuleDetails
@@ -257,9 +255,25 @@ export const getServerSideProps = wrapper.getServerSideProps(
}
await createContainerProxy(thisSession.user.id);
const accountDetails = await getPersonalAccount(loggedInUser);
if (accountDetails?.errorCode) {
let accountDetails;
try {
accountDetails = await getCrmPersonalAccount(loggedInUser);
} catch (error) {
consoleLogger({
name: "MyPortalIndexAccountLookup",
reasonCode: "UPSTREAM_FAILURE",
message: "myportal index personal account lookup failed",
error: error?.message
});
return {
redirect: { destination: "/myportal/error", permanent: false }
};
}
if (!accountDetails || accountDetails.errorCode) {
return {
redirect: { destination: "/myportal/error", permanent: false }
};