Skip to content

Commit de60e76

Browse files
authored
Merge pull request #208 from prgrms-web-devcourse-final-project/fix/207-kakao-login
[chore] 배포서버에서 카카오 로그인시 code 유효성 확인
2 parents b52b10d + 1eeaa0e commit de60e76

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

src/components/KaKaoRedirection.tsx

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
1-
import { getKakaoLogin } from '@/apis/auth';
1+
// import { getKakaoLogin } from '@/apis/auth';
22
import Loading from '@/components/loading/Loading';
3-
import { useAuthStore } from '@/store/authStore';
3+
// import { useAuthStore } from '@/store/authStore';
44
import { useEffect } from 'react';
5-
import { useNavigate } from 'react-router';
5+
// import { useNavigate } from 'react-router';
66

77
function KaKaoRedirection() {
8-
const navigate = useNavigate();
8+
// const navigate = useNavigate();
99
const kakaoCode = new URL(window.location.href).searchParams.get('code');
10-
const { setAccessToken } = useAuthStore();
10+
// const { setAccessToken } = useAuthStore();
1111

12-
const handleKaKaoLogin = async () => {
13-
try {
14-
console.log('kakaoCode', kakaoCode);
15-
const { code, data } = await getKakaoLogin(kakaoCode as string);
16-
if (code === 200) {
17-
setAccessToken(data.accessToken);
18-
navigate('/home');
19-
} else {
20-
throw new Error('로그인 에러');
21-
}
22-
} catch (error) {
23-
console.error('로그인 에러가 발생했습니다.');
24-
}
25-
};
12+
// const handleKaKaoLogin = async () => {
13+
// try {
14+
// console.log('kakaoCode', kakaoCode);
15+
// const { code, data } = await getKakaoLogin(kakaoCode as string);
16+
// if (code === 200) {
17+
// setAccessToken(data.accessToken);
18+
// navigate('/home');
19+
// } else {
20+
// throw new Error('로그인 에러');
21+
// }
22+
// } catch (error) {
23+
// console.error('로그인 에러가 발생했습니다.');
24+
// }
25+
// };
2626

2727
useEffect(() => {
28-
if (kakaoCode) handleKaKaoLogin();
28+
if (kakaoCode) {
29+
console.log('🔴 kakaoCode', kakaoCode);
30+
// handleKaKaoLogin();
31+
}
2932
}, []);
3033
return <Loading />;
3134
}

0 commit comments

Comments
 (0)