-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
65 additions
and
30 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
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,44 @@ | ||
import { UserInfoState } from '@recoil/Auth.atom'; | ||
import { setItem } from '@utils/localStorageFun'; | ||
import { useEffect } from 'react'; | ||
import { useNavigate, useSearchParams } from 'react-router-dom'; | ||
import { useSetRecoilState } from 'recoil'; | ||
|
||
const KakaoLogin = () => { | ||
const setUserInfo = useSetRecoilState(UserInfoState); | ||
const navigate = useNavigate(); | ||
|
||
const [searchParams, _] = useSearchParams(); | ||
const nickname = searchParams.get('nickname'); | ||
const email = searchParams.get('email'); | ||
const gender = searchParams.get('gender'); | ||
const age_range = searchParams.get('age_range'); | ||
const accessToken = searchParams.get('token'); | ||
const profile_image = searchParams.get('profile_image'); | ||
const signup = searchParams.get('signup'); | ||
|
||
useEffect(() => { | ||
if (accessToken) { | ||
setItem('accessToken', accessToken); | ||
setUserInfo({ | ||
nickname: nickname!, | ||
email: email!, | ||
profileImageUrl: profile_image, | ||
ageType: age_range, | ||
genderType: gender, | ||
survey: null, | ||
}); | ||
if (signup) { | ||
navigate('/signup/success'); | ||
} else { | ||
navigate('/'); | ||
} | ||
} else { | ||
alert('로그인에 실패했습니다. 다시 시도해주세요.'); | ||
navigate('/login'); | ||
} | ||
}, []); | ||
return <>카카오 로그인 중입니다.</>; | ||
}; | ||
|
||
export default KakaoLogin; |
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,5 +1,6 @@ | ||
import LoginLogo from './LoginLogo'; | ||
import LoginForm from './LoginForm'; | ||
import AuthButtonsWrapper from './AuthButtons/AuthButtonsWrapper'; | ||
import KakaoLogin from './KakaoLogin'; | ||
|
||
export { LoginLogo, LoginForm, AuthButtonsWrapper }; | ||
export { LoginLogo, LoginForm, AuthButtonsWrapper, KakaoLogin }; |
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,18 +1,7 @@ | ||
import { useEffect } from 'react'; | ||
import { KakaoLogin } from '@components/Auth/Login'; | ||
|
||
const LoginKakao = () => { | ||
const code = new URL(window.location.href).searchParams.get('code'); | ||
|
||
useEffect(() => { | ||
console.log(code); | ||
try { | ||
// const res = postKakaoLogin(); | ||
} catch (err) { | ||
console.log('카카오 로그인 중 에러 발생'); | ||
} | ||
}, []); | ||
|
||
return <div>잠시만 기다려주세요</div>; | ||
return <KakaoLogin />; | ||
}; | ||
|
||
export default LoginKakao; |
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