diff --git a/src/pages/External.tsx b/src/pages/External.tsx deleted file mode 100644 index 5cb8dbf..0000000 --- a/src/pages/External.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import React from "react"; -import { useLocation } from "react-router-dom"; -import { EXT_LOAD_ID } from "../constants"; - -interface IStateProps {} -interface IDispatchProps {} - -type MyProps = IStateProps & IDispatchProps; - -interface LocationState { - from: { - pathname: string; - }; -} - -const External: React.FC = (props: MyProps) => { - const location = useLocation(); - console.log(location); - const currentLocationState: LocationState = location.state || { - from: { pathname: "/homex" }, - }; - console.log(currentLocationState); - - const getUrlParameter = (name: any) => { - name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - const regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); - - const results = regex.exec(location ? location.search : ""); - return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); - }; - const id = getUrlParameter("id"); - if (id.length > 0) { - console.log("issue load request for " + id); - window.sessionStorage.setItem(EXT_LOAD_ID, id); - } - return ( -
-

Irgendwas

- {/*

{currentLocationState}

*/} -
- ); -}; -export default External; diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx deleted file mode 100644 index 3546146..0000000 --- a/src/pages/Home.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { useKeycloak } from "@react-keycloak/web"; -import * as React from "react"; -import { useCallback } from "react"; - -export default () => { - const { keycloak } = useKeycloak(); - - const callApi = useCallback(() => { - console.log("log something"); - }, []); - - return ( -
-
User is {!keycloak?.authenticated ? "NOT " : ""} authenticated
- - {!!keycloak?.authenticated && ( - - )} - - -
- ); -}; diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx deleted file mode 100644 index 2598640..0000000 --- a/src/pages/Login.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { useKeycloak } from "@react-keycloak/web"; -import * as React from "react"; -import { useCallback } from "react"; -import { Redirect, useLocation } from "react-router-dom"; - -interface LocationState { - from: { - pathname: string; - }; -} -const LoginPage = () => { - const location = useLocation(); - console.log(location); - const currentLocationState: LocationState = location.state || { - from: { pathname: "/home" }, - }; - - const { keycloak } = useKeycloak(); - - const login = useCallback(() => { - keycloak?.login(); - }, [keycloak]); - - console.log(currentLocationState); - if (keycloak?.authenticated) return ; - - return <>; -}; - -export default LoginPage; diff --git a/src/routes/auth.tsx b/src/routes/auth.tsx index 81c4b8d..442ab98 100644 --- a/src/routes/auth.tsx +++ b/src/routes/auth.tsx @@ -24,7 +24,7 @@ export const AuthProvider = ({ children }) => { }; const tokenLogger = (tokens: unknown) => { - console.log("onKeycloakTokens", tokens); + // console.log("onKeycloakTokens", tokens); }; // const handleLogin = useCallback(() => { diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 90e2405..1f82a65 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,6 +1,7 @@ import { useKeycloak } from "@react-keycloak/web"; import * as React from "react"; -import { BrowserRouter, Route, Routes } from "react-router-dom"; +import { BrowserRouter, Navigate, Route, Routes, useLocation } from "react-router-dom"; +import { EXT_LOAD_ID } from "../constants"; import TabContainer from "../container/tabContainer"; import { useAuth } from "./auth"; import { PrivateRoute } from "./utils"; @@ -10,6 +11,20 @@ const Home = () => { if (!name) return

Please use the login button.

; return ; }; + +const External = () => { + const location = useLocation(); + + const regex = new RegExp("id=(?[a-f0-9\\-]{36})"); + const results = regex.exec(location.search); + if (results === null) { + return

Invalid query parameters.

; + } + + window.sessionStorage.setItem(EXT_LOAD_ID, results[1]); + return ; +}; + const Unknown = () => { return

NotMatched route

; }; @@ -25,6 +40,7 @@ export const AppRouter = () => { } /> + } /> { ); + // http://localhost:3000/ext?id=caa3d195-9ed0-47e2-84a8-db008f76358c // return ( //