Route portal login hashing through authenticated signer

This commit is contained in:
2026-03-13 14:01:18 +00:00
parent 82f891ada8
commit 6094874851
4 changed files with 63 additions and 13 deletions
+21 -1
View File
@@ -3,6 +3,26 @@ import { BASE_URL } from "../core/env";
import { consoleLogger } from "../core/logger";
import { hashAPIPath } from "../core/hash";
const buildHashedQueryUrl = async (queryUrl) => {
try {
const signRes = await axios.get(
"/api/endpoint/gethash_api?path=" + encodeURIComponent(queryUrl)
);
if (!signRes?.data?.hash) {
throw new Error("Hash signature unavailable");
}
return queryUrl + signRes.data.hash;
} catch (error) {
if (typeof window === "undefined" && process.env.HASHKEY) {
return queryUrl + hashAPIPath(queryUrl);
}
throw error;
}
};
export const getPersonalAccount = (contactid) => {
return axios
.get(
@@ -105,7 +125,7 @@ export const getPortalLogin = async (emailAddress) => {
"/api/endpoint/getportallogin_api?emailAddress=" + emailAddress;
return axios
.get(BASE_URL + queryUrl + hashAPIPath(queryUrl))
.get(BASE_URL + (await buildHashedQueryUrl(queryUrl)))
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);