sending the auth from libracart to the add endpoints
This commit is contained in:
parent
767ca5ef97
commit
093ad7b2ad
3 changed files with 21 additions and 12 deletions
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -10889,7 +10889,7 @@
|
||||||
},
|
},
|
||||||
"node_modules/protobuf-ts": {
|
"node_modules/protobuf-ts": {
|
||||||
"version": "1.0.0",
|
"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": {
|
"dependencies": {
|
||||||
"protobufjs": "^6.8.8"
|
"protobufjs": "^6.8.8"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,27 +25,22 @@ export default function LibraCartAccess() {
|
||||||
const [primaryUser, setPrimaryUser] = useState("");
|
const [primaryUser, setPrimaryUser] = useState("");
|
||||||
const [libracartUsername, setLibraCartUserName] = useState("");
|
const [libracartUsername, setLibraCartUserName] = useState("");
|
||||||
const [libracartCode, setLibraCartCode] = useState<string | null>("");
|
const [libracartCode, setLibraCartCode] = useState<string | null>("");
|
||||||
|
const [libracartAuth, setLibraCartAuth] = useState<string | null>("");
|
||||||
//const [activeStep, setActiveStep] = useState<number>(0);
|
//const [activeStep, setActiveStep] = useState<number>(0);
|
||||||
const userAPI = useUserAPI();
|
const userAPI = useUserAPI();
|
||||||
const libracartAPI = useLibraCartProxyAPI();
|
const libracartAPI = useLibraCartProxyAPI();
|
||||||
//const [dataOps, setDataOps] = useState<pond.DataOption[]>([]);
|
//const [dataOps, setDataOps] = useState<pond.DataOption[]>([]);
|
||||||
const { openSnack } = useSnackbar();
|
const { openSnack } = useSnackbar();
|
||||||
const search = useLocation().search;
|
|
||||||
const searchParams = new URLSearchParams(search);
|
|
||||||
//const [{ as }] = useGlobalState();
|
//const [{ as }] = useGlobalState();
|
||||||
// const integration_url = process.env.REACT_APP_LIBRACART_INTEGRATION_URL;
|
// const integration_url = process.env.REACT_APP_LIBRACART_INTEGRATION_URL;
|
||||||
const integration_url = import.meta.env.VITE_LIBRACART_INTEGRATION_URL;
|
const integration_url = import.meta.env.VITE_LIBRACART_INTEGRATION_URL;
|
||||||
|
|
||||||
|
|
||||||
const submitNewOrganization = () => {
|
const submitNewOrganization = () => {
|
||||||
if (libracartCode) {
|
if (libracartCode && libracartAuth) {
|
||||||
libracartAPI
|
libracartAPI
|
||||||
.addAccount(teamKey, primaryUser, libracartCode, libracartUsername)
|
.addAccount(teamKey, primaryUser, libracartCode, libracartAuth, libracartUsername)
|
||||||
.then(resp => {
|
.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");
|
openSnack("Added New Libra Cart Account Link");
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
@ -72,9 +67,12 @@ export default function LibraCartAccess() {
|
||||||
// }, [searchParams, libracartCode]);
|
// }, [searchParams, libracartCode]);
|
||||||
|
|
||||||
useEffect(() => {
|
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
|
let code = new URLSearchParams(window.location.search).get("state"); // this is the account_code
|
||||||
if (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);
|
setLibraCartCode(code);
|
||||||
|
setLibraCartAuth(auth);
|
||||||
setOpenDialog(true);
|
setOpenDialog(true);
|
||||||
}
|
}
|
||||||
}, [window.location]);
|
}, [window.location]);
|
||||||
|
|
@ -133,7 +131,14 @@ export default function LibraCartAccess() {
|
||||||
fullWidth
|
fullWidth
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={libracartCode}
|
value={libracartCode}
|
||||||
onChange={e => setLibraCartCode(e.target.value)}
|
/>
|
||||||
|
<TextField
|
||||||
|
margin="dense"
|
||||||
|
label="authorization token"
|
||||||
|
disabled
|
||||||
|
fullWidth
|
||||||
|
variant="outlined"
|
||||||
|
value={libracartAuth}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ export interface ILibraCartProxyAPIContext {
|
||||||
teamKey: string,
|
teamKey: string,
|
||||||
userID: string,
|
userID: string,
|
||||||
libracartCode: string,
|
libracartCode: string,
|
||||||
|
libracartAuth: string,
|
||||||
libracartUsername: string
|
libracartUsername: string
|
||||||
) => Promise<AxiosResponse<pond.AddLibraCartAccountResponse>>;
|
) => Promise<AxiosResponse<pond.AddLibraCartAccountResponse>>;
|
||||||
//list organizations
|
//list organizations
|
||||||
|
|
@ -51,6 +52,7 @@ export default function LibraCartProvider(props: PropsWithChildren<Props>) {
|
||||||
teamKey: string,
|
teamKey: string,
|
||||||
userID: string,
|
userID: string,
|
||||||
libracartCode: string,
|
libracartCode: string,
|
||||||
|
libracartAuth: string,
|
||||||
libracartUsername: string
|
libracartUsername: string
|
||||||
) => {
|
) => {
|
||||||
return post<pond.AddLibraCartAccountResponse>(
|
return post<pond.AddLibraCartAccountResponse>(
|
||||||
|
|
@ -61,6 +63,8 @@ export default function LibraCartProvider(props: PropsWithChildren<Props>) {
|
||||||
userID +
|
userID +
|
||||||
"&code=" +
|
"&code=" +
|
||||||
libracartCode +
|
libracartCode +
|
||||||
|
"&auth=" +
|
||||||
|
libracartAuth +
|
||||||
"&libracartUsername=" +
|
"&libracartUsername=" +
|
||||||
libracartUsername
|
libracartUsername
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue