diff --git a/FE/src/App.js b/FE/src/App.js index 3abdb82..6c8b0b8 100644 --- a/FE/src/App.js +++ b/FE/src/App.js @@ -38,7 +38,8 @@ function App() { const [userState, setUserState] = useRecoilState(userAtom); useLayoutEffect(() => { - const accessToken = localStorage.getItem("accessToken"); + let accessToken = localStorage.getItem("accessToken"); + accessToken = accessToken || sessionStorage.getItem("accessToken"); if (accessToken) { setUserState({ ...userState, isLogin: true, accessToken }); } diff --git a/FE/src/components/LoginModal/LoginModal.js b/FE/src/components/LoginModal/LoginModal.js index 5d4ef76..261364c 100644 --- a/FE/src/components/LoginModal/LoginModal.js +++ b/FE/src/components/LoginModal/LoginModal.js @@ -14,6 +14,7 @@ import naver from "../../assets/naver.png"; function LoginModal() { const [userId, setUserId] = useState(""); + const [keepLogin, setKeepLogin] = useState(false); const [password, setPassword] = useState(""); const setUserState = useSetRecoilState(userAtom); const setHeaderState = useSetRecoilState(headerAtom); @@ -40,7 +41,11 @@ function LoginModal() { isLogin: true, accessToken: data.accessToken, })); - localStorage.setItem("accessToken", data.accessToken); + if (keepLogin) { + localStorage.setItem("accessToken", data.accessToken); + } else { + sessionStorage.setItem("accessToken", data.accessToken); + } } else { errorRef.current.innerText = data.message; } @@ -87,7 +92,11 @@ function LoginModal() { onChange={(e) => setPassword(e.target.value)} /> - +
로그인 유지
@@ -97,7 +106,15 @@ function LoginModal() { 로그인 - + { + setHeaderState((prev) => ({ + ...prev, + isLogin: false, + isSignUp: true, + })); + }} + >
회원가입
아이디/비밀번호 찾기
@@ -165,6 +182,8 @@ const HelpBar = styled.div` font-size: 1rem; color: #ffffff; + + cursor: pointer; `; const HelpBarBorder = styled.div` diff --git a/FE/src/components/SideBar/SideBar.js b/FE/src/components/SideBar/SideBar.js index 00aa015..755ce95 100644 --- a/FE/src/components/SideBar/SideBar.js +++ b/FE/src/components/SideBar/SideBar.js @@ -62,6 +62,7 @@ function SideBar() { accessToken: "", })); localStorage.removeItem("accessToken"); + sessionStorage.removeItem("accessToken"); }} > 로그아웃