Merged PR 2315: Auth stabilistatiion and hardening

Related work items: #23020
This commit is contained in:
Robert Bond
2026-05-14 08:55:49 +00:00
parent d295a507ac
commit d0b2fd077a
41 changed files with 1462 additions and 418 deletions
+51 -4
View File
@@ -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);