fix: clear local cache on logout (#519)

This commit is contained in:
Philip Okugbe
2024-11-28 20:35:53 +00:00
committed by GitHub
parent 311d81bc71
commit c6aaefecbd

View File

@ -23,6 +23,7 @@ import { acceptInvitation } from "@/features/workspace/services/workspace-servic
import Cookies from "js-cookie";
import { jwtDecode } from "jwt-decode";
import APP_ROUTE from "@/lib/app-route.ts";
import { useQueryClient } from "@tanstack/react-query";
export default function useAuth() {
const [isLoading, setIsLoading] = useState(false);
@ -30,6 +31,7 @@ export default function useAuth() {
const [, setCurrentUser] = useAtom(currentUserAtom);
const [authToken, setAuthToken] = useAtom(authTokensAtom);
const queryClient = useQueryClient();
const handleSignIn = async (data: ILogin) => {
setIsLoading(true);
@ -136,7 +138,8 @@ export default function useAuth() {
setAuthToken(null);
setCurrentUser(null);
Cookies.remove("authTokens");
navigate(APP_ROUTE.AUTH.LOGIN);
queryClient.clear();
window.location.replace(APP_ROUTE.AUTH.LOGIN);;
};
const handleForgotPassword = async (data: IForgotPassword) => {