mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
fix: clear local cache on logout (#519)
This commit is contained in:
@@ -23,6 +23,7 @@ import { acceptInvitation } from "@/features/workspace/services/workspace-servic
|
|||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
import { jwtDecode } from "jwt-decode";
|
import { jwtDecode } from "jwt-decode";
|
||||||
import APP_ROUTE from "@/lib/app-route.ts";
|
import APP_ROUTE from "@/lib/app-route.ts";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
export default function useAuth() {
|
export default function useAuth() {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
@@ -30,6 +31,7 @@ export default function useAuth() {
|
|||||||
|
|
||||||
const [, setCurrentUser] = useAtom(currentUserAtom);
|
const [, setCurrentUser] = useAtom(currentUserAtom);
|
||||||
const [authToken, setAuthToken] = useAtom(authTokensAtom);
|
const [authToken, setAuthToken] = useAtom(authTokensAtom);
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const handleSignIn = async (data: ILogin) => {
|
const handleSignIn = async (data: ILogin) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
@@ -136,7 +138,8 @@ export default function useAuth() {
|
|||||||
setAuthToken(null);
|
setAuthToken(null);
|
||||||
setCurrentUser(null);
|
setCurrentUser(null);
|
||||||
Cookies.remove("authTokens");
|
Cookies.remove("authTokens");
|
||||||
navigate(APP_ROUTE.AUTH.LOGIN);
|
queryClient.clear();
|
||||||
|
window.location.replace(APP_ROUTE.AUTH.LOGIN);;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleForgotPassword = async (data: IForgotPassword) => {
|
const handleForgotPassword = async (data: IForgotPassword) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user