-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
175 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// GoogleLoginButton.tsx | ||
|
||
import React from 'react'; | ||
|
||
interface Props { | ||
backendURL: string; | ||
} | ||
|
||
const GoogleLoginButton: React.FC<Props> = ({ backendURL }) => { | ||
const handleLoginClick = () => { | ||
window.location.href = `${backendURL}`; | ||
}; | ||
|
||
return ( | ||
<button onClick={handleLoginClick}> | ||
Login with Google | ||
</button> | ||
); | ||
} | ||
|
||
export default GoogleLoginButton; | ||
|
||
|
||
|
||
// const authToken = response.headers["authorization"]; | ||
// console.log(authToken); | ||
|
||
// const refreshToken = response.headers["refresh"]; | ||
|
||
// // 로그인 상태로 만들기 | ||
// dispatch(setLoginState()); | ||
|
||
// // 토큰들을 로컬 스토리지에 저장 | ||
// if (authToken) localStorage.setItem("authToken", authToken); | ||
// if (refreshToken) localStorage.setItem("refreshToken", refreshToken); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// KakaoLoginButton.tsx | ||
|
||
import React from 'react'; | ||
|
||
interface Props { | ||
backendURL: string; | ||
} | ||
|
||
const KakaoLoginButton: React.FC<Props> = ({ backendURL }) => { | ||
const handleLoginClick = () => { | ||
window.location.href = `${backendURL}`; | ||
}; | ||
|
||
return ( | ||
<button onClick={handleLoginClick}> | ||
Login with Kakao | ||
</button> | ||
); | ||
} | ||
|
||
export default KakaoLoginButton; | ||
|
||
// 토큰 저장 로직 | ||
|
||
// const authToken = response.headers["authorization"]; | ||
// console.log(authToken); | ||
|
||
// const refreshToken = response.headers["refresh"]; | ||
|
||
// // 로그인 상태로 만들기 | ||
// dispatch(setLoginState()); | ||
|
||
// // 토큰들을 로컬 스토리지에 저장 | ||
// if (authToken) localStorage.setItem("authToken", authToken); | ||
// if (refreshToken) localStorage.setItem("refreshToken", refreshToken); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Google Login</title> | ||
</head> | ||
<body> | ||
<div> | ||
<a href="/oauth2/authorization/google">Google 로그인</a> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// TokenHandler.tsx | ||
|
||
import React, { useEffect } from 'react'; | ||
import { useDispatch } from "react-redux"; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { setLoginState } from "../../reducer/member/loginSlice"; | ||
|
||
const TokenHandler: React.FC = () => { | ||
const dispatch = useDispatch(); | ||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
const urlParams = new URLSearchParams(window.location.search); | ||
const accessToken = urlParams.get("access_token"); | ||
const refreshToken = urlParams.get("refresh_token"); | ||
|
||
if (accessToken && refreshToken) { | ||
localStorage.setItem("Authorization", `Bearer ${accessToken}`); | ||
localStorage.setItem("Refresh-token", refreshToken); | ||
dispatch(setLoginState()); | ||
navigate('/'); | ||
} | ||
}, [dispatch, navigate]); | ||
|
||
return null; // 이 컴포넌트는 UI를 렌더링하지 않습니다. | ||
}; | ||
|
||
export default TokenHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.