Skip to content

Commit

Permalink
hotfix: logout 서버 로직 변경으로 api 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
eastfilmm committed Jun 8, 2024
1 parent 0f5d89e commit d8ab63d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions src/apis/auth/auth.api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'axios';

import { BASE_URI } from '@finnect/constants/URI';
import { axiosClient } from '../AxiosClient';

interface AuthAPIRequest {
result: any;
Expand Down Expand Up @@ -35,8 +36,23 @@ export async function logout(): Promise<AuthAPIRequest> {
const response = await axios.post(`${BASE_URI}/users/signout`, {
withCredentials: true,
});
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
localStorage.clear();
console.log('sign out successfully');
return response.data;
} catch (error) {
console.error('Error during sign out:', error);
throw error;
}
}

export async function logout2(): Promise<AuthAPIRequest> {
const refreshToken = localStorage.getItem('refreshToken');
try {
const response = await axiosClient.post(`${BASE_URI}/users/signout2`, {
refreshToken,
withCredentials: true,
});
localStorage.clear();
console.log('sign out successfully');
return response.data;
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/header/HeaderSubMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
selectedInviteModalState,
} from '@finnect/atoms/header/useHeaderMenu';
import InviteModal from '@finnect/components/common/modal/header/InviteModal';
import { logout } from '@finnect/apis/auth/auth.api';
import { logout2 } from '@finnect/apis/auth/auth.api';
import { useNavigate } from 'react-router-dom';

const { Text } = Typography;
Expand All @@ -26,7 +26,7 @@ const HeaderSubMenu = () => {

const handleMenuClick = (e: any) => {
if (e.key === 'logout') {
logout();
logout2();
navigate('/signin');
console.log('로그아웃');
return message.success('로그아웃 성공.');
Expand Down

0 comments on commit d8ab63d

Please sign in to comment.