refactor: migrate myportal index account lookup to server helper
This commit is contained in:
+20
-6
@@ -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 }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user