Redirect on token expiry

This commit is contained in:
april
2024-01-04 13:36:21 -06:00
parent 9de454d491
commit 4e84dc842a
10 changed files with 116 additions and 34 deletions

View File

@@ -13,6 +13,7 @@ interface AuthContextValues {
password: string;
}) => void;
signout: () => void;
clearUser: () => void;
}
const AuthContext = createContext<AuthContextValues | null>(null);
@@ -86,6 +87,10 @@ function useProvideAuth() {
return await client.post("/auth/logout").then(() => handleUser(null));
};
const clearUser = () => {
handleUser(null);
};
useEffect(() => {
client
.get("/users/me")
@@ -99,5 +104,6 @@ function useProvideAuth() {
loading,
signin,
signout,
clearUser,
};
}