From 0087147660cb3ddd22add7f01cce71bb18ed075a Mon Sep 17 00:00:00 2001 From: KaiserBh <41852205+KaiserBh@users.noreply.github.com> Date: Mon, 17 Apr 2023 02:54:27 +1000 Subject: [PATCH] fix(web): unrecoverable unauthorized error (#843) fix:unauthorized error. added check for failed login as well remove user when visiting login. Co-authored-by: KaiserBh --- web/src/screens/auth/login.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/web/src/screens/auth/login.tsx b/web/src/screens/auth/login.tsx index 27b6af0..8bc4efc 100644 --- a/web/src/screens/auth/login.tsx +++ b/web/src/screens/auth/login.tsx @@ -7,6 +7,8 @@ import { APIClient } from "../../api/APIClient"; import { AuthContext } from "../../utils/Context"; import { PasswordInput, TextInput } from "../../components/inputs/text"; import { Tooltip } from "react-tooltip"; +import Toast from "@/components/notifications/Toast"; +import toast from "react-hot-toast"; type LoginFormFields = { username: string; @@ -22,6 +24,12 @@ export const Login = () => { const [, setAuthContext] = AuthContext.use(); useEffect(() => { + // remove user session when visiting login page' + APIClient.auth.logout() + .then(() => { + AuthContext.reset(); + }); + // Check if onboarding is available for this instance // and redirect if needed APIClient.auth.canOnboard() @@ -38,6 +46,11 @@ export const Login = () => { isLoggedIn: true }); navigate("/"); + }, + onError: () => { + toast.custom((t) => ( + + )); } } );