-
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.
Browse files
Browse the repository at this point in the history
구글 로그인, apple로그인 구현, 기존 카카오톡 로그인 사용자를 위한 데이터 이전 로직 구현
- Loading branch information
Showing
34 changed files
with
515 additions
and
112 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 |
---|---|---|
@@ -1,17 +1,29 @@ | ||
import ApiClient from './apiClient'; | ||
|
||
export const login = async (loginInputInfo: { nickname: string }) => { | ||
const response = await ApiClient.postWithoutAuth( | ||
'/auth/login', | ||
loginInputInfo, | ||
); | ||
return response.json(); | ||
}; | ||
|
||
export const kakaoOAuth = async (code: string) => { | ||
const response = await ApiClient.postWithoutAuth('/auth/kakao/oauth', { | ||
code, | ||
}); | ||
console.log(response); | ||
return response.json(); | ||
}; | ||
export const appleOAuth = async ( | ||
code: string, | ||
memberId: string | null = null, | ||
) => { | ||
const response = await ApiClient.postWithoutAuth('/auth/apple/oauth', { | ||
code, | ||
memberId, | ||
}); | ||
return response.json(); | ||
}; | ||
|
||
export const googleOAuth = async ( | ||
idToken: string, | ||
memberId: string | null = null, | ||
) => { | ||
const response = await ApiClient.postWithoutAuth('/auth/google/oauth', { | ||
idToken, | ||
memberId, | ||
}); | ||
return response.json(); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
40 changes: 40 additions & 0 deletions
40
frontend/src/components/GoogleLoginButton/GoogleLoginButton.tsx
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,40 @@ | ||
import ROUTES from '@_constants/routes'; | ||
import { useEffect, useRef } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
function GoogleLoginButton() { | ||
const navigate = useNavigate(); | ||
const g_sso = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
if (g_sso.current) { | ||
window.google.accounts.id.initialize({ | ||
client_id: process.env.GOOGLE_O_AUTH_CLIENT_ID, | ||
callback: handleGoogleSignIn, | ||
ux_mode: 'popup', | ||
}); | ||
|
||
window.google.accounts.id.renderButton(g_sso.current, { | ||
theme: 'outline', | ||
size: 'large', | ||
width: 269, | ||
}); | ||
} | ||
}, [g_sso]); | ||
|
||
const handleGoogleSignIn = (response: { | ||
credential: string; | ||
error: string; | ||
}) => { | ||
if (response.error && response.error === 'AbortError') { | ||
console.error('요청이 중단되었습니다. 다시 시도하세요.'); | ||
return; | ||
} | ||
console.log('Google JWT Token: ', response.credential); | ||
navigate(`${ROUTES.oAuthGoogle}/google?code=${response.credential}`); | ||
}; | ||
|
||
return <div ref={g_sso}></div>; | ||
} | ||
|
||
export default GoogleLoginButton; |
Oops, something went wrong.