Skip to content

Commit

Permalink
fix: login status maintain
Browse files Browse the repository at this point in the history
  • Loading branch information
jun-brro committed Mar 18, 2024
1 parent 2d044dc commit 67b83b4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions my-app/src/components/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,16 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
);

useEffect(() => {
const sessionExists = !!cookies["sessionId"];
const sessionExists = !!cookies.sessionId;
setIsLoggedIn(sessionExists);
}, [cookies, setIsLoggedIn]);
}, [cookies.sessionId, setIsLoggedIn]);

useEffect(() => {
const session = localStorage.getItem("isLoggedIn");
if (session === "true") {
setIsLoggedIn(true);
}
});

const login = async (loginId: string, password: string) => {
try {
Expand Down

0 comments on commit 67b83b4

Please sign in to comment.