Skip to content

Commit

Permalink
[Feat] 구글 oauth로그인 구현
Browse files Browse the repository at this point in the history
구글 로그인 라이브러리 최신화
구글로그인 컴포넌트를 logins폴더에 생성
Issues #15
  • Loading branch information
김병현 authored and 김병현 committed Sep 12, 2023
1 parent 8daf55c commit 04842c0
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
10 changes: 10 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@react-oauth/google": "^0.11.1",
"@reduxjs/toolkit": "^1.9.5",
"axios": "^1.5.0",
"boxicons": "^2.1.4",
Expand Down
33 changes: 33 additions & 0 deletions client/src/components/Logins/GoogleSignin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { GoogleOAuthProvider, GoogleLogin, useGoogleOneTapLogin } from '@react-oauth/google';

const GoogleSignInComponent: React.FC = () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handleSuccess = (credentialResponse: any) => {
console.log(credentialResponse);
};

const handleError = () => {
console.log('Login Failed');
};

// One-tap 로그인 (선택적)
useGoogleOneTapLogin({
onSuccess: handleSuccess,
onError: handleError,
});

return (
<GoogleOAuthProvider clientId="
690344785644-2oj84rcukd2rhu3o56gbq6rahap16m37.apps.googleusercontent.com">
<GoogleLogin
onSuccess={handleSuccess}
onError={handleError}
useOneTap
/>
</GoogleOAuthProvider>
);
};

export default GoogleSignInComponent;

4 changes: 2 additions & 2 deletions client/src/components/Logins/OAuthLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import styled from 'styled-components';

import GoogleLogin from './GoogleSignin.tsx'
import kakaoLogo from '../../asset/images/KakaoLogo.svg';
import axios from 'axios';

Expand Down Expand Up @@ -34,7 +34,7 @@ const OAuthLoginModal: React.FC<LoginModalProps> = ({ onClose, onEmailLoginClick
<ModalContainer>
<CloseButton onClick={onClose}>&times;</CloseButton>
<Title>{titleText}</Title>

<GoogleLogin/>
<KakaoButton onClick={handleKakaoLogin}>
<LogoImage src={kakaoLogo} alt="Kakao Logo" />
{kakaoLoginText}
Expand Down

0 comments on commit 04842c0

Please sign in to comment.