Skip to content

Commit ed07cd3

Browse files
committed
Refact: 로그인 로직 변경
1 parent 7c089cd commit ed07cd3

5 files changed

Lines changed: 14 additions & 133 deletions

File tree

src/App.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import Login from './pages/Login';
55
import SignUp from './pages/SignUp';
66
import LoginComplete from './pages/Login/components/LoginComplete';
77
import TermsAgreement from './pages/TermsAgreement';
8-
import KakaoCallback from './pages/Login/components/Kakao/KakaoCallback';
9-
import NaverCallback from './pages/Login/components/Naver/NaverCallback';
108

119
import MyPage from './pages/MyPage';
1210
import ProfileEdit from './pages/ProfileEdit';
@@ -65,10 +63,6 @@ const publicRoutes = [
6563
{ path: '/signup', element: <SignUp /> },
6664
{ path: '/login/complete', element: <LoginComplete /> },
6765
{ path: '/terms-agreement', element: <TermsAgreement /> },
68-
69-
// 콜백
70-
{ path: '/auth/kakao/callback', element: <KakaoCallback /> },
71-
{ path: '/auth/naver/callback', element: <NaverCallback /> },
7266
];
7367

7468
const App: React.FC = () => {

src/pages/Login/components/Kakao/KakaoCallback.tsx

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/pages/Login/components/Kakao/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import { StyledText } from '../../../../components/Text/StyledText';
77
import kakao from '../../../../assets/default/snsIcon/kakao.svg';
88

99
const Kakao: React.FC = () => {
10-
const REST_API_KEY = import.meta.env.VITE_KAKAO_REST_API_KEY;
11-
const REDIRECT_URI = encodeURIComponent(
12-
import.meta.env.VITE_DOMAIN
13-
? import.meta.env.VITE_DOMAIN + '/auth/kakao/callback'
14-
: 'http://localhost:3000/auth/kakao/callback',
15-
);
10+
const SERVER_URI = import.meta.env.VITE_NEW_API_URL;
1611

1712
const handleLogin = () => {
18-
window.location.href = `https://kauth.kakao.com/oauth/authorize?client_id=${REST_API_KEY}&redirect_uri=${REDIRECT_URI}&response_type=code`;
13+
// 리다이렉트 URL 설정 및 서버 URL 생성
14+
const redirectUrl = 'http://localhost:3000/login/complete';
15+
const serverUrl = `${SERVER_URI}/auth/login/kakao?redirectUrl=${redirectUrl}`;
16+
17+
// 서버로 리다이렉션
18+
window.open(serverUrl, '_self');
1919
};
2020

2121
return (

src/pages/Login/components/Naver/NaverCallback.tsx

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/pages/Login/components/Naver/index.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ import { SocialLogin, TextWrapper, LogoImgWrapper, LogoImage } from '../style';
77
import naver from '../../../../assets/default/snsIcon/naver.svg';
88

99
const Naver: React.FC = () => {
10-
console.log(import.meta.env.VITE_DOMAIN);
11-
const clientId = import.meta.env.VITE_NAVER_CLIENT_ID; // 네이버 개발자 센터에서 받은 클라이언트 ID
12-
const redirectUri = encodeURIComponent(
13-
import.meta.env.VITE_DOMAIN
14-
? import.meta.env.VITE_DOMAIN + '/auth/naver/callback'
15-
: 'http://localhost:3000/auth/naver/callback',
16-
);
10+
const SERVER_URI = import.meta.env.VITE_NEW_API_URL;
1711

1812
const handleLogin = () => {
19-
window.location.href = `https://nid.naver.com/oauth2.0/authorize?response_type=code&client_id=${clientId}&redirect_uri=${redirectUri}&state=STATE_TOKEN`;
13+
// 리다이렉트 URL 설정 및 서버 URL 생성
14+
const redirectUrl = 'http://localhost:3000/login/complete';
15+
const serverUrl = `${SERVER_URI}/auth/login/naver?redirectUrl=${redirectUrl}`;
16+
17+
// 서버로 리다이렉션
18+
window.open(serverUrl, '_self');
2019
};
2120

2221
return (

0 commit comments

Comments
 (0)