From c5780df58eed3247dccfad76e4dde1f0b83341dc Mon Sep 17 00:00:00 2001 From: Tim Chamberlain Date: Mon, 14 Nov 2022 15:46:44 -0600 Subject: [PATCH] SPRINT-15: fixed unauthorized user bug --- src/HandleAuthorizationError.tsx | 12 +++++++++++- src/index.tsx | 12 +++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/HandleAuthorizationError.tsx b/src/HandleAuthorizationError.tsx index 6abbaf0..0bedfa9 100644 --- a/src/HandleAuthorizationError.tsx +++ b/src/HandleAuthorizationError.tsx @@ -19,26 +19,36 @@ * along with this program. If not, see . */ +import {Auth0Provider, useAuth0} from "@auth0/auth0-react"; import React, {useEffect} from "react"; import {useCookies} from "react-cookie"; import {SESSION_ID_COOKIE_NAME} from "App"; +import {AUTH0_CLIENT_ID, AUTH0_DOMAIN} from "index"; interface Props { errorMessage?: string; } + function HandleAuthorizationError({errorMessage}: Props) { + const [, , removeCookie] = useCookies([SESSION_ID_COOKIE_NAME]); + const {logout} = useAuth0(); useEffect(() => { + logout(); removeCookie(SESSION_ID_COOKIE_NAME, {path: "/"}); }); return ( -
{errorMessage}
+ +
+
{errorMessage}
+
+
); } diff --git a/src/index.tsx b/src/index.tsx index 86cf484..95ebc2a 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -29,8 +29,8 @@ import {MaterialUIControllerProvider} from "context"; import HandleAuthorizationError from "HandleAuthorizationError"; import ProtectedRoute from "qqq/auth0/protected-route"; -const domain = process.env.REACT_APP_AUTH0_DOMAIN; -const clientId = process.env.REACT_APP_AUTH0_CLIENT_ID; +export const AUTH0_DOMAIN = process.env.REACT_APP_AUTH0_DOMAIN; +export const AUTH0_CLIENT_ID = process.env.REACT_APP_AUTH0_CLIENT_ID; // @ts-ignore function Auth0ProviderWithRedirectCallback({children, ...props}) @@ -47,7 +47,9 @@ function Auth0ProviderWithRedirectCallback({children, ...props}) { return ( // @ts-ignore - + + + ); } else @@ -64,8 +66,8 @@ function Auth0ProviderWithRedirectCallback({children, ...props}) render(