fixing redirect stuff
This commit is contained in:
parent
424b75afb8
commit
f8fb4b7c7d
4 changed files with 23 additions and 24 deletions
|
|
@ -45,11 +45,16 @@ function App() {
|
||||||
// if (!client_id) client_id = import.meta.env.VITE_AUTH0_CLIENT_ID;
|
// if (!client_id) client_id = import.meta.env.VITE_AUTH0_CLIENT_ID;
|
||||||
|
|
||||||
//check the url for a code before auth0 causes a login re-direct
|
//check the url for a code before auth0 causes a login re-direct
|
||||||
if (window.location.pathname !== "/callback") {
|
// if (window.location.pathname !== "/callback") {
|
||||||
//set the code into local storage
|
// //set the code into local storage
|
||||||
let code = new URLSearchParams(window.location.search).get("code");
|
// let code = new URLSearchParams(window.location.search).get("code");
|
||||||
sessionStorage.setItem("code", code || "")
|
// sessionStorage.setItem("code", code || "")
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
const skipCallbacks = [
|
||||||
|
"/johndeere",
|
||||||
|
"/cnhi"
|
||||||
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppThemeProvider>
|
<AppThemeProvider>
|
||||||
|
|
@ -60,6 +65,7 @@ function App() {
|
||||||
audience: or(audience, ""),
|
audience: or(audience, ""),
|
||||||
redirect_uri: window.location.origin + "/callback"
|
redirect_uri: window.location.origin + "/callback"
|
||||||
}}
|
}}
|
||||||
|
skipRedirectCallback={skipCallbacks.includes(window.location.pathname)}
|
||||||
useRefreshTokens={true}
|
useRefreshTokens={true}
|
||||||
cacheLocation='localstorage'
|
cacheLocation='localstorage'
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { teamScope, User } from "models";
|
||||||
import { pond } from "protobuf-ts/pond";
|
import { pond } from "protobuf-ts/pond";
|
||||||
import { useSnackbar, useUserAPI, useCNHiProxyAPI } from "providers";
|
import { useSnackbar, useUserAPI, useCNHiProxyAPI } from "providers";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useLocation } from "react-router";
|
//import { useLocation } from "react-router";
|
||||||
import TeamSearch from "teams/TeamSearch";
|
import TeamSearch from "teams/TeamSearch";
|
||||||
|
|
||||||
export default function CNHiAccess() {
|
export default function CNHiAccess() {
|
||||||
|
|
@ -29,8 +29,8 @@ export default function CNHiAccess() {
|
||||||
const cnhiAPI = useCNHiProxyAPI();
|
const cnhiAPI = useCNHiProxyAPI();
|
||||||
//const [dataOps, setDataOps] = useState<pond.DataOption[]>([]);
|
//const [dataOps, setDataOps] = useState<pond.DataOption[]>([]);
|
||||||
const { openSnack } = useSnackbar();
|
const { openSnack } = useSnackbar();
|
||||||
const search = useLocation().search;
|
//const search = useLocation().search;
|
||||||
const searchParams = new URLSearchParams(search);
|
//const searchParams = new URLSearchParams(search);
|
||||||
//const [{ as }] = useGlobalState();
|
//const [{ as }] = useGlobalState();
|
||||||
const client_id = import.meta.env.VITE_CNHI_CLIENT_ID;
|
const client_id = import.meta.env.VITE_CNHI_CLIENT_ID;
|
||||||
const auth_url = import.meta.env.VITE_CNHI_AUTHORIZE_URL;
|
const auth_url = import.meta.env.VITE_CNHI_AUTHORIZE_URL;
|
||||||
|
|
@ -44,10 +44,6 @@ export default function CNHiAccess() {
|
||||||
cnhiAPI
|
cnhiAPI
|
||||||
.addAccount(teamKey, primaryUser, cnhiCode, cnhiUsername)
|
.addAccount(teamKey, primaryUser, cnhiCode, cnhiUsername)
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
//the code was used so remove it from local storage
|
|
||||||
if (localStorage.getItem("code")) {
|
|
||||||
localStorage.removeItem("code");
|
|
||||||
}
|
|
||||||
openSnack("Added New Case New Holland Account Link");
|
openSnack("Added New Case New Holland Account Link");
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
@ -66,12 +62,12 @@ export default function CNHiAccess() {
|
||||||
}, [teamKey, userAPI]);
|
}, [teamKey, userAPI]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let code = localStorage.getItem("code");
|
let code = new URLSearchParams(window.location.search).get("code");
|
||||||
if (code) {
|
if (code) {
|
||||||
setCNHiCode(code);
|
setCNHiCode(code);
|
||||||
setOpenDialog(true);
|
setOpenDialog(true);
|
||||||
}
|
}
|
||||||
}, [searchParams, cnhiCode]);
|
}, [window.location, cnhiCode]);
|
||||||
|
|
||||||
const validate = () => {
|
const validate = () => {
|
||||||
let invalid = false;
|
let invalid = false;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { teamScope, User } from "models";
|
||||||
import { pond } from "protobuf-ts/pond";
|
import { pond } from "protobuf-ts/pond";
|
||||||
import { useSnackbar, useUserAPI, useJohnDeereProxyAPI } from "providers";
|
import { useSnackbar, useUserAPI, useJohnDeereProxyAPI } from "providers";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useLocation } from "react-router";
|
//import { useLocation } from "react-router";
|
||||||
import TeamSearch from "teams/TeamSearch";
|
import TeamSearch from "teams/TeamSearch";
|
||||||
|
|
||||||
//const steps = [{label: "General"},{label: "Data Options"}]
|
//const steps = [{label: "General"},{label: "Data Options"}]
|
||||||
|
|
@ -31,13 +31,14 @@ export default function JDAccess() {
|
||||||
const johnDeereAPI = useJohnDeereProxyAPI();
|
const johnDeereAPI = useJohnDeereProxyAPI();
|
||||||
//const [dataOps, setDataOps] = useState<pond.DataOption[]>([]);
|
//const [dataOps, setDataOps] = useState<pond.DataOption[]>([]);
|
||||||
const { openSnack } = useSnackbar();
|
const { openSnack } = useSnackbar();
|
||||||
const search = useLocation().search;
|
//const search = useLocation().search;
|
||||||
const searchParams = new URLSearchParams(search);
|
//const searchParams = new URLSearchParams(search);
|
||||||
//const [{ as }] = useGlobalState();
|
//const [{ as }] = useGlobalState();
|
||||||
//const MAPBOX_TOKEN = import.meta.env.VITE_MAPBOX_ACCESS_TOKEN;
|
//const MAPBOX_TOKEN = import.meta.env.VITE_MAPBOX_ACCESS_TOKEN;
|
||||||
const client_id = import.meta.env.VITE_JD_CLIENT_ID;
|
const client_id = import.meta.env.VITE_JD_CLIENT_ID;
|
||||||
const auth_url = import.meta.env.VITE_JD_AUTHORIZE_URL;
|
const auth_url = import.meta.env.VITE_JD_AUTHORIZE_URL;
|
||||||
const redirect_url = import.meta.env.VITE_JD_REDIRECT_URI;
|
const redirect_url = import.meta.env.VITE_JD_REDIRECT_URI;
|
||||||
|
//const redirect_url = "http://localhost:5173/johndeere";//local redirect for testing
|
||||||
const scopes = import.meta.env.VITE_JD_SCOPES;
|
const scopes = import.meta.env.VITE_JD_SCOPES;
|
||||||
const state = import.meta.env.VITE_JD_STATE;
|
const state = import.meta.env.VITE_JD_STATE;
|
||||||
|
|
||||||
|
|
@ -48,10 +49,6 @@ export default function JDAccess() {
|
||||||
johnDeereAPI
|
johnDeereAPI
|
||||||
.addAccount(teamKey, primaryUser, jdCode, jdUserName)
|
.addAccount(teamKey, primaryUser, jdCode, jdUserName)
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
//the code was used so remove it from local storage
|
|
||||||
if (sessionStorage.getItem("code")) {
|
|
||||||
sessionStorage.removeItem("code");
|
|
||||||
}
|
|
||||||
openSnack("Added New John Deere Account Link");
|
openSnack("Added New John Deere Account Link");
|
||||||
window.open(
|
window.open(
|
||||||
`https://connections.deere.com/connections/${client_id}/select-organizations`
|
`https://connections.deere.com/connections/${client_id}/select-organizations`
|
||||||
|
|
@ -73,12 +70,12 @@ export default function JDAccess() {
|
||||||
}, [teamKey, userAPI]);
|
}, [teamKey, userAPI]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let code = sessionStorage.getItem("code");
|
let code = new URLSearchParams(window.location.search).get("code");
|
||||||
if (code) {
|
if (code) {
|
||||||
setJDCode(code);
|
setJDCode(code);
|
||||||
setOpenDialog(true);
|
setOpenDialog(true);
|
||||||
}
|
}
|
||||||
}, [searchParams, jdCode]);
|
}, [window.location, jdCode]);
|
||||||
|
|
||||||
const validate = () => {
|
const validate = () => {
|
||||||
let invalid = false;
|
let invalid = false;
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ export default function CNHi() {
|
||||||
//style={{ maxWidth: 110 }}
|
//style={{ maxWidth: 110 }}
|
||||||
title="John Deer Account"
|
title="John Deer Account"
|
||||||
displayEmpty
|
displayEmpty
|
||||||
disableUnderline={true}
|
//disableUnderline={true}
|
||||||
value={currentOrg}
|
value={currentOrg}
|
||||||
onChange={(event: any) => {
|
onChange={(event: any) => {
|
||||||
setCurrentOrg(event.target.value);
|
setCurrentOrg(event.target.value);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue