Skip to content

Commit 52512d4

Browse files
committed
Store is_authenticated state in localStorage instead of access_token
1 parent eef9b87 commit 52512d4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

frontend/src/hooks/useAuth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { handleError } from "@/utils"
1414

1515
const isLoggedIn = () => {
16-
return localStorage.getItem("access_token") !== null
16+
return localStorage.getItem("is_authenticated") !== null
1717
}
1818

1919
const useAuth = () => {
@@ -45,7 +45,7 @@ const useAuth = () => {
4545
const response = await LoginService.loginAccessToken({
4646
formData: data,
4747
})
48-
localStorage.setItem("access_token", response.access_token)
48+
localStorage.setItem("is_authenticated", "true")
4949
}
5050

5151
const loginMutation = useMutation({
@@ -61,7 +61,7 @@ const useAuth = () => {
6161
const logout = async () => {
6262
try {
6363
await LoginService.logout();
64-
localStorage.removeItem("access_token");
64+
localStorage.removeItem("is_authenticated");
6565
navigate({ to: "/login" });
6666
} catch (error) {
6767
console.error("Logout failed:", error);

0 commit comments

Comments
 (0)