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
+121 -45
View File
@@ -9,6 +9,7 @@ import {
} from "../../actions/services/caseService";
import { getRepsFromBlob } from "../../actions/services/documentService";
import { getBasicSearch } from "../../actions/services/searchService";
import { consoleLogger } from "../../actions/core/logger";
import {
getFormCollectionByID,
getSearchDetails
@@ -41,7 +42,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 = "";
@@ -75,19 +76,21 @@ const getDetails = (resultsObj, detailsType) => {
}
let detArr = Promise.all(detailsArr);
console.log(detArr);
return detArr;
};
export const loadRepresentationBootstrap = async ({ ctx }) => {
const { query } = ctx;
console.log("The query", query);
let thisSession = await getSession(ctx);
let loggedInUser = {};
let loggedInUser = null;
if (!thisSession) {
console.log("not has sesssion.......");
consoleLogger({
name: "RepresentationLoaderMissingSession",
message:
"loadRepresentationBootstrap missing session; redirecting to signin"
});
return {
redirect: {
destination: "/auth/signin",
@@ -95,22 +98,28 @@ export const loadRepresentationBootstrap = async ({ ctx }) => {
}
};
} else {
[loggedInUser] = await Promise.all([
await getPortalLogin(thisSession.user.email)
]);
loggedInUser = await getPortalLogin(thisSession.user.email);
loggedInUser = loggedInUser?.value?.[0]?.contactid || null;
}
console.log(
"=====//////////=====",
thisSession,
thisSession.user.email,
loggedInUser
);
loggedInUser = loggedInUser.value[0].contactid;
if (!loggedInUser) {
consoleLogger({
name: "RepresentationLoaderMissingContact",
message:
"loadRepresentationBootstrap missing CRM contact id; redirecting to signin",
hasSessionEmail: !!thisSession?.user?.email
});
return {
redirect: {
destination: "/auth/signin",
permanent: false
}
};
}
const [accountDetails, myRepresentations] = await Promise.all([
await getPersonalAccount(loggedInUser),
await getRepsFromBlob(thisSession.user.id)
getPersonalAccount(loggedInUser),
getRepsFromBlob(thisSession.user.id)
]);
const myRepresentationsDetails = await getDetails(
@@ -118,10 +127,8 @@ export const loadRepresentationBootstrap = async ({ ctx }) => {
"myRepresentations"
);
console.log(accountDetails);
const isLPA =
accountDetails[
accountDetails?.[
"pinswg_typeofinvolvement@OData.Community.Display.V1.FormattedValue"
] == "LPA"
? true
@@ -148,9 +155,22 @@ export const loadExistingRepresentation = async ({ store, ctx, bootstrap }) => {
isLPA
} = bootstrap;
console.log("is lpa?:", isLPA);
const searchResultsObj = await getBasicSearch(query.case);
if (!searchResultsObj?.value?.[0]) {
consoleLogger({
name: "RepresentationExistingMissingSearchResult",
message:
"loadExistingRepresentation missing search result; redirecting to myportal",
hasCaseQuery: !!query?.case
});
return {
redirect: {
destination: "/myportal",
permanent: false
}
};
}
const searchDetailsObj = await getSearchDetails(searchResultsObj);
store.dispatch(setSearchResults(searchResultsObj));
@@ -164,11 +184,26 @@ export const loadExistingRepresentation = async ({ store, ctx, bootstrap }) => {
}
const result = findObjectByKeyValue(
myRepresentations.value,
myRepresentations?.value || [],
"repfile_name",
query.created
);
if (!result) {
consoleLogger({
name: "RepresentationExistingMissingBlobEntry",
message:
"loadExistingRepresentation missing representation blob entry; redirecting to myportal",
hasCreatedQuery: !!query?.created
});
return {
redirect: {
destination: "/myportal",
permanent: false
}
};
}
store.dispatch(
setCurrentReference({
"ticketnumber":
@@ -206,6 +241,21 @@ export const loadNewRepresentation = async ({ store, ctx, bootstrap }) => {
const { thisSession, accountDetails } = bootstrap;
const searchResultsObj = await getBasicSearch(query.case);
if (!searchResultsObj?.value?.[0]) {
consoleLogger({
name: "RepresentationNewMissingSearchResult",
message:
"loadNewRepresentation missing search result; redirecting to myportal",
hasCaseQuery: !!query?.case
});
return {
redirect: {
destination: "/myportal",
permanent: false
}
};
}
const searchDetailsObj = await getSearchDetails(searchResultsObj);
store.dispatch(setContainerID(thisSession.user.id));
@@ -219,31 +269,26 @@ export const loadNewRepresentation = async ({ store, ctx, bootstrap }) => {
})
);
console.log(
accountDetails,
"===================== is nrw",
accountDetails.emailaddress1.includes(process.env.NRWDOMAIN),
"===================== "
);
store.dispatch(
setCurrentReference({
"isNRW":
accountDetails.emailaddress1.includes(process.env.NRWDOMAIN) ||
false,
"ticketnumber": searchResultsObj.value[0].ticketnumber,
"currentReference": searchResultsObj.value[0].title,
accountDetails?.emailaddress1?.includes(
process.env.NRWDOMAIN
) || false,
"ticketnumber": searchResultsObj?.value?.[0]?.ticketnumber,
"currentReference": searchResultsObj?.value?.[0]?.title,
"currentType": "myRepresentations",
"incidentid": searchResultsObj.value[0].incidentid,
"appealType": searchResultsObj.value[0].pinswg_appealcasetype,
"incidentid": searchResultsObj?.value?.[0]?.incidentid,
"appealType": searchResultsObj?.value?.[0]?.pinswg_appealcasetype,
"specialistProcess":
searchDetailsObj[0].value[0].pinswg_speacialistcaseprocess !=
null ||
searchDetailsObj[0].value[0].pinswg_specialistcaseprocess !=
null
? searchDetailsObj[0].value[0]
searchDetailsObj?.[0]?.value?.[0]
?.pinswg_speacialistcaseprocess != null ||
searchDetailsObj?.[0]?.value?.[0]
?.pinswg_specialistcaseprocess != null
? searchDetailsObj?.[0]?.value?.[0]
.pinswg_speacialistcaseprocess ||
searchDetailsObj[0].value[0].pinswg_specialistcaseprocess
searchDetailsObj?.[0]?.value?.[0]
.pinswg_specialistcaseprocess
: ""
})
);
@@ -259,15 +304,46 @@ export const loadNewRepresentation = async ({ store, ctx, bootstrap }) => {
};
export const loadRepresentationPage = async ({ store, ctx }) => {
const { query } = ctx;
if (!query?.case) {
consoleLogger({
name: "RepresentationLoaderMissingCaseQuery",
message:
"loadRepresentationPage missing case query; redirecting to myportal"
});
return {
redirect: {
destination: "/myportal",
permanent: false
}
};
}
if (
Object.prototype.hasOwnProperty.call(query, "state") &&
!query?.created
) {
consoleLogger({
name: "RepresentationLoaderMissingCreatedQuery",
message:
"loadRepresentationPage missing created query for state flow; redirecting to myportal"
});
return {
redirect: {
destination: "/myportal",
permanent: false
}
};
}
const bootstrap = await loadRepresentationBootstrap({ ctx });
if (bootstrap?.redirect) {
return bootstrap;
}
const { query } = ctx;
if (query.hasOwnProperty("state")) {
if (Object.prototype.hasOwnProperty.call(query, "state")) {
return loadExistingRepresentation({ store, ctx, bootstrap });
}