Skip to content

Commit

Permalink
feat: 토큰 저장 장소 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
localgaji committed Nov 5, 2023
1 parent 1ec813a commit a7233d3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/utils/loginDatahandlers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const storage: Storage = localStorage;

export const saveLoginData = (token: string, userData: UserDataType) => {
sessionStorage.removeItem('beforeLoginURL');

Expand All @@ -7,11 +9,11 @@ export const saveLoginData = (token: string, userData: UserDataType) => {
isAdmin: userData.isAdmin,
};

sessionStorage.setItem('login', JSON.stringify(loginData));
storage.setItem('login', JSON.stringify(loginData));
};

export const removeLoginData = () => {
sessionStorage.removeItem('login');
storage.removeItem('login');
location.reload();
};

Expand All @@ -22,7 +24,7 @@ const defaultLoginState = {
};

export const getLoginData = () => {
const stringData = sessionStorage.getItem('login');
const stringData = storage.getItem('login');
if (stringData === null) return defaultLoginState;

return JSON.parse(stringData);
Expand Down

0 comments on commit a7233d3

Please sign in to comment.