Skip to content

Commit

Permalink
feat: logout api 요청 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yeopto committed Oct 6, 2023
1 parent 12c237f commit 0d0e473
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions frontend/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const requestPostOAuthLogin = (provider: OAuthProvider, code: string) =>
body: JSON.stringify({ oauthProvider: provider, code }),
});

export const requestPostLogout = () => http.post(`/api/auth/logout`);

export const requestGetMemberInfo = () => http.get<ResponseMemberInfo>('/api/me');

export const requestGetOneStudyData = async (studyId: string) => {
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/contexts/MemberInfoProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ROUTES_PATH } from '@Constants/routes';
import tokenStorage from '@Utils/tokenStorage';
import url from '@Utils/url';

import { requestGetMemberInfo } from '@Apis/index';
import { requestGetMemberInfo, requestPostLogout } from '@Apis/index';

import type { MemberInfo } from '@Types/member';

Expand All @@ -35,8 +35,9 @@ const MemberInfoProvider = ({ children }: PropsWithChildren) => {
const actions: Actions = useMemo(
() => ({
refetchMemberInfo: refetch,
clearMemberInfo: () => {
tokenStorage.clear();
clearMemberInfo: async () => {
tokenStorage.removeAccessToken();
await requestPostLogout();
clearResult();
navigate(ROUTES_PATH.landing);
},
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/mocks/handlers/authHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { hasCookie } from '@Utils/cookie';
import { ACCESS_TOKEN, NEW_ACCESS_TOKEN, USER_DATA } from '../mockData';

export const authHandler = [
// 로그아웃 API
rest.post('api/auth/logout', (req, res, ctx) => {
return res(ctx.status(200));
}),

// 게스트 로그인 API
rest.post('/api/auth/guest', (req, res, ctx) => {
return res(
Expand Down

0 comments on commit 0d0e473

Please sign in to comment.