-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ORT-2] feat: add KakaoLoginButton #2
Changes from 6 commits
e3a2327
b6fe479
9488104
e91bc63
49d03a1
62e4927
e0c2842
505907d
ed6b270
dd22322
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { useMemo } from 'react'; | ||
import getUUID from '@/utils/getUUID'; | ||
|
||
const clientId = 'f5aa2f20e42d783654b8e8c01bfc6312'; | ||
//redirectUri는 등록된 redirectUri중에 임의로 사용했습니다. | ||
const redirectUri = 'http://localhost:5173/oauth/kakao'; | ||
|
||
const KakaoLoginButton: React.FC = () => { | ||
const kakaoAuthUrl = useMemo(() => { | ||
const userUUID = getUUID(); | ||
return `https://kauth.kakao.com/oauth/authorize?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=code&state=${userUUID}`; | ||
}, []); | ||
|
||
return ( | ||
<a href={kakaoAuthUrl}> | ||
<button>카카오로 로그인</button> | ||
</a> | ||
); | ||
}; | ||
|
||
export default KakaoLoginButton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import KakaoLoginButton from './KakaoLoginButton'; | ||
|
||
export default KakaoLoginButton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { LoaderFunction, json } from '@remix-run/cloudflare'; | ||
import axios, { AxiosError } from 'axios'; | ||
|
||
export const loader: LoaderFunction = async ({ request }) => { | ||
const url = new URL(request.url); | ||
const code = url.searchParams.get('code'); | ||
const state = url.searchParams.get('state'); | ||
|
||
try { | ||
const response = await axios.post('(백엔드api url)', { | ||
code, | ||
state, | ||
}); | ||
return json({ message: 'Success', data: response.data }); | ||
} catch (error) { | ||
const axiosError = error as AxiosError; | ||
console.error('Error sending code to backend:', axiosError); | ||
return json({ message: 'Error', error: axiosError.message }); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 코드 부분 혹시 지워주실 수 있을까요? 제가 이어서 작업하겠습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 지우면 커밋이 불가해서 대충 // 이 아래의 try문 지우고 이어서 하면 됩니다
try {
console.log(code, state);
} catch {
console.log(json);
}
}; |
||
}; | ||
|
||
const KakaoRedirect = () => <div>카카오 로그인 중...</div>; | ||
|
||
export default KakaoRedirect; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
//이용자의 uuid를 받아옵니다. | ||
const getUUID = () => { | ||
const getUserUUID = (): string => uuidv4(); | ||
return getUserUUID; | ||
}; | ||
crew852 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default getUUID; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 한 파일에 하나의 함수만 넣는 방식인 것 같은데, 그러기엔 코드가 너무 짧아 보여서 그냥 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그게 맞는 것 같긴 한데, 이 외에 이 함수와 같이 들어갈 만한 다른 함수가 생각나지 않아서 이렇게 작성했습니다. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -21,9 +21,11 @@ | |||||
"@remix-run/react": "2.10.2", | ||||||
"@remix-run/serve": "2.10.2", | ||||||
"@vanilla-extract/css": "1.15.3", | ||||||
"axios": "^1.7.4", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 라이브러리 지워주실 수 있을까요? 제가 API 부분 작업하려고 합니다! |
||||||
"isbot": "4.4.0", | ||||||
"react": "18.3.1", | ||||||
"react-dom": "18.3.1" | ||||||
"react-dom": "18.3.1", | ||||||
"uuid": "^10.0.0" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오...이건 그냥 몰랐습니다 |
||||||
}, | ||||||
"devDependencies": { | ||||||
"@commitlint/cli": "19.3.0", | ||||||
|
@@ -39,6 +41,7 @@ | |||||
"@storybook/test": "8.2.5", | ||||||
"@types/react": "18.3.3", | ||||||
"@types/react-dom": "18.3.0", | ||||||
"@types/uuid": "^10.0.0", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"@typescript-eslint/eslint-plugin": "7.16.0", | ||||||
"@typescript-eslint/parser": "7.16.0", | ||||||
"@vanilla-extract/vite-plugin": "4.0.13", | ||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
우선은 상관없지만, 제가 Env 관련 작업을 하고 나면 환경변수로 변경하면 좋을 듯합니다!