Skip to content

Commit

Permalink
fix: 로그아웃시 로컬스토리지 유저 정보 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
wildcatco committed Sep 3, 2023
1 parent 1c8d68b commit df4b170
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/features/user/utils/user-local-storage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GetUserResponse } from '@/features/user/queries/dto/get-user';

const USER_LOCAL_STORAGE_KEY = 'GOCHAM-USER';
const USER_UPDATED_AT_STORAGE_KEY = 'GOCHAM-USER-UPDATED-AT';
export const USER_LOCAL_STORAGE_KEY = 'GOCHAM-USER';
export const USER_UPDATED_AT_STORAGE_KEY = 'GOCHAM-USER-UPDATED-AT';

export const userLocalStorage = {
saveUser: (user: GetUserResponse) => {
Expand Down
6 changes: 6 additions & 0 deletions src/pages/settings/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { useNavigate } from 'react-router-dom';
import BackIcon from '@/common/components/icons/BackIcon';
import TopAppBar from '@/common/components/layout/TopAppBar';
import Popup from '@/common/components/ui/modal/Popup';
import {
USER_LOCAL_STORAGE_KEY,
USER_UPDATED_AT_STORAGE_KEY,
} from '@/features/user/utils/user-local-storage';

export default function SettingsPage() {
const navigate = useNavigate();
Expand Down Expand Up @@ -45,6 +49,8 @@ export default function SettingsPage() {
alert('로그아웃 되었습니다.\n고민이 있으면 언제든지 찾아와주세요!');
sessionStorage.removeItem('selectMyPostTypeLabel');
localStorage.removeItem('token');
localStorage.removeItem(USER_LOCAL_STORAGE_KEY);
localStorage.removeItem(USER_UPDATED_AT_STORAGE_KEY);
queryClient.clear();
navigate('/');
};
Expand Down

0 comments on commit df4b170

Please sign in to comment.