SPRINT-15: fixed unauthorized user bug

This commit is contained in:
Tim Chamberlain
2022-11-14 15:46:44 -06:00
parent de630e2bd6
commit c5780df58e
2 changed files with 18 additions and 6 deletions

View File

@ -19,26 +19,36 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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 (
<div>{errorMessage}</div>
<Auth0Provider domain={AUTH0_DOMAIN} clientId={AUTH0_CLIENT_ID}>
<div>
<div>{errorMessage}</div>
</div>
</Auth0Provider>
);
}