Skip to content

Commit

Permalink
#122 [FEAT] 로그인 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kimhyerims committed Dec 25, 2024
1 parent eb7cb42 commit d752bad
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/apis/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { authAxios, testAxios } from '../axios';

// 로그인
export const kakaoLoginAPI = async () => {
const response = await testAxios.get(`/login`);
// const loginUrl = `https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=856122255feeea21d537c0225f6c658a&redirect_uri=http://localhost:8080/auth/kakao/callback`;
const loginUrl = `https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=856122255feeea21d537c0225f6c658a&redirect_uri=https://wellet.store/auth/kakao/callback`;
window.location.href = loginUrl;
};
12 changes: 10 additions & 2 deletions src/axios/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ export const authAxios = axios.create({
},
});

export const testAxios = axios.create({
// baseURL: "http://localhost:8080",
baseURL: 'https://wellet.store',
withCredentials: true,
headers: {
'Content-Type': 'application/json',
},
});

const getTokenFromCookie = () => {
// const cookie = document.cookie
// .split('; ')
Expand All @@ -18,8 +27,7 @@ const getTokenFromCookie = () => {
return dummyToken;
};

const dummyToken =
'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIzODQ1Njk3MjEwIiwicm9sZSI6IlVTRVIiLCJuaWNrbmFtZSI6Iuq5gO2YnOumvCIsImlkIjozODQ1Njk3MjEwLCJleHAiOjE3MzQ4Nzk5ODIsImlhdCI6MTczNDg3NjM4MiwidXNlcm5hbWUiOiIwMTVmZDUwNy0zNWJiLTQxNmYtYjQ4OC03Y2JiN2NjYTQ0NjQifQ.Glv2-tcXLiqhI3TasBvC9WmS9P7YE7-AC1RnS9gzl_x0hfBxW5jfcTvsqBS7D6o40rbBKUPU8Iscvs1PsDiB2g';
const dummyToken = '토큰값';
// 요청을 보낼 때 Bearer Token을 Authorization 헤더에 추가합니다.
authAxios.interceptors.request.use(
(config) => {
Expand Down
16 changes: 15 additions & 1 deletion src/pages/LoginPage/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@ import login_background_lines from '../../assets/images/login_background_lines.s
import { PrimaryButton, SecondaryButton } from '../../components';
import { useNavigate } from 'react-router-dom';

// import { kakaoLoginAPI, getUserInfo } from '../../apis/login';
import { kakaoLoginAPI } from '../../apis/login';

export default function LoginPage() {
const navigate = useNavigate();

async function kakaoLogin() {
try {
const response = await kakaoLoginAPI(); // 카카오 로그인 API 호출
} catch (error) {
// 로그인 실패 시 처리
alert('로그인 실패. 다시 시도.' + error);
}
}

return (
<S.Container
style={{ backgroundImage: `url(${login_background_circles})` }}
Expand All @@ -24,7 +36,9 @@ export default function LoginPage() {
color: '#1A1A1C',
gap: '2px',
}}
onClick={() => navigate('/home')}
// onClick={() => navigate('/home')}
// onClick={() => kakaoLogin }
onClick={kakaoLogin}
>
<S.KakaoIcon>
<Icon id='kakao' />
Expand Down

0 comments on commit d752bad

Please sign in to comment.