Skip to content

Commit

Permalink
feat: 세션 및 accessToken 저장 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yechan-kim committed Nov 18, 2024
1 parent 731769d commit 4c75974
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/hooks/useAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ export const useAuth = () => {
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
localStorage.removeItem('username');
localStorage.removeItem('session');
setUsername(null);
};

const handleCallback = async (code) => {
try {
const backendResponse = await axios.get(`${import.meta.env.VITE_DEFAULT_API_URI}/login?code=${code}`);
const { accessToken, refreshToken, username } = backendResponse.data;
const { accessToken, refreshToken, username, session } = backendResponse.data;

localStorage.setItem('accessToken', accessToken);
localStorage.setItem('refreshToken', refreshToken);
localStorage.setItem('username', username);
localStorage.setItem('session', session);

setUsername(username);
} catch (error) {
Expand Down

0 comments on commit 4c75974

Please sign in to comment.