Route portal login hashing through authenticated signer
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user