sending the auth from libracart to the add endpoints

This commit is contained in:
csawatzky 2025-07-18 13:46:07 -06:00
parent 767ca5ef97
commit 093ad7b2ad
3 changed files with 21 additions and 12 deletions

2
package-lock.json generated
View file

@ -10889,7 +10889,7 @@
},
"node_modules/protobuf-ts": {
"version": "1.0.0",
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#174342d58e3d36bda2f2efc08aa3c95a217125e1",
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#e1a765ee24fd1c6e374fd6d7a21edb82feb45c6f",
"dependencies": {
"protobufjs": "^6.8.8"
}

View file

@ -25,27 +25,22 @@ export default function LibraCartAccess() {
const [primaryUser, setPrimaryUser] = useState("");
const [libracartUsername, setLibraCartUserName] = useState("");
const [libracartCode, setLibraCartCode] = useState<string | null>("");
const [libracartAuth, setLibraCartAuth] = useState<string | null>("");
//const [activeStep, setActiveStep] = useState<number>(0);
const userAPI = useUserAPI();
const libracartAPI = useLibraCartProxyAPI();
//const [dataOps, setDataOps] = useState<pond.DataOption[]>([]);
const { openSnack } = useSnackbar();
const search = useLocation().search;
const searchParams = new URLSearchParams(search);
//const [{ as }] = useGlobalState();
// const integration_url = process.env.REACT_APP_LIBRACART_INTEGRATION_URL;
const integration_url = import.meta.env.VITE_LIBRACART_INTEGRATION_URL;
const submitNewOrganization = () => {
if (libracartCode) {
if (libracartCode && libracartAuth) {
libracartAPI
.addAccount(teamKey, primaryUser, libracartCode, libracartUsername)
.addAccount(teamKey, primaryUser, libracartCode, libracartAuth, libracartUsername)
.then(resp => {
//the code was used so remove it from local storage
if (localStorage.getItem("code")) {
localStorage.removeItem("code");
}
openSnack("Added New Libra Cart Account Link");
})
.catch(err => {
@ -72,9 +67,12 @@ export default function LibraCartAccess() {
// }, [searchParams, libracartCode]);
useEffect(() => {
let code = new URLSearchParams(window.location.search).get("state"); // not sure if the state is correct here i thought it should be the access_token
if (code) {
let code = new URLSearchParams(window.location.search).get("state"); // this is the account_code
let auth = new URLSearchParams(window.location.search).get("authorization_token"); // this is the authorization used to verify where it came from
if (code && auth) {
setLibraCartCode(code);
setLibraCartAuth(auth);
setOpenDialog(true);
}
}, [window.location]);
@ -133,7 +131,14 @@ export default function LibraCartAccess() {
fullWidth
variant="outlined"
value={libracartCode}
onChange={e => setLibraCartCode(e.target.value)}
/>
<TextField
margin="dense"
label="authorization token"
disabled
fullWidth
variant="outlined"
value={libracartAuth}
/>
</Box>
);

View file

@ -11,6 +11,7 @@ export interface ILibraCartProxyAPIContext {
teamKey: string,
userID: string,
libracartCode: string,
libracartAuth: string,
libracartUsername: string
) => Promise<AxiosResponse<pond.AddLibraCartAccountResponse>>;
//list organizations
@ -51,6 +52,7 @@ export default function LibraCartProvider(props: PropsWithChildren<Props>) {
teamKey: string,
userID: string,
libracartCode: string,
libracartAuth: string,
libracartUsername: string
) => {
return post<pond.AddLibraCartAccountResponse>(
@ -61,6 +63,8 @@ export default function LibraCartProvider(props: PropsWithChildren<Props>) {
userID +
"&code=" +
libracartCode +
"&auth=" +
libracartAuth +
"&libracartUsername=" +
libracartUsername
)