Skip to content

Commit

Permalink
feat: 로그아웃 후 뒤로가기 클릭으로 마이페이지 접근 불가 기능
Browse files Browse the repository at this point in the history
  • Loading branch information
jiohjung98 committed Sep 12, 2024
1 parent 505ca2b commit 211c66b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/app/mypage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const Mypage = () => {

useEffect(() => {
const checkLoginStatus = async () => {
const isLoggedIn = !!localStorage.getItem('access_token');
if (!isLoggedIn) {
const accessToken = localStorage.getItem('access_token');
if (!accessToken || accessToken === 'undefined') {
router.push('/sign');
} else {
setLoading(false);
setLoading(false);
}
};

Expand All @@ -28,6 +28,7 @@ const Mypage = () => {
const handleLogout = async () => {
await logout();
setIsLoggedIn(false);
localStorage.removeItem('access_token'); // Remove access token from local storage
router.push('/sign');
};

Expand Down
3 changes: 2 additions & 1 deletion src/components/common/Gnb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const Gnb = () => {

useEffect(() => {
const accessToken = localStorage.getItem('access_token');
if (accessToken) {

if (accessToken && accessToken !== 'undefined') {
setIsLoggedIn(true);
} else {
setIsLoggedIn(false);
Expand Down

0 comments on commit 211c66b

Please sign in to comment.