-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feat/#5: 카카오 로그인 구현 #8
Conversation
- accessToken 저장 구현
const authOptions: NextAuthOptions = { | ||
providers: [ | ||
KakaoProvider({ | ||
clientId: process.env.KAKAO_CLIENT_ID as string, | ||
clientSecret: process.env.KAKAO_CLIENT_SECRET as string, | ||
}), | ||
], | ||
session: { | ||
strategy: 'jwt', //JWT 기반 인증 | ||
maxAge: 24 * 60 * 60, // 24시간 | ||
}, | ||
secret: process.env.NEXTAUTH_SECRET, //JWT 암호화 키 설정 | ||
callbacks: { | ||
async signIn({ user }) { | ||
return !!user.email; | ||
}, | ||
async jwt({ token, account }) { | ||
if (account) { | ||
token.accessToken = account.access_token; | ||
token.refreshToken = account.refresh_token; | ||
} | ||
return token; | ||
}, | ||
async session({ session, token }) { | ||
session.accessToken = token.accessToken as string; | ||
return session; | ||
}, | ||
}, | ||
}; |
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.
- providers: 카카오만 등록되어 있고, 이곳에 애플을 등록하시면 됩니다.
- session, secret: jwt관련 설정
- callbacks
- jwt: token 등록
- session: session 등록
- signIn: user의 email이 없다면 로그인에 실패하도록 설정했습니다. (저희는 email로 구분을 하니까요!)
auth에 대한 구조를 위와 같이 구성했습니다.
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.
구조 확인했어요 ! 정리해주신덕에 조금은 수월하게 작업하지 않을까 싶네요 !
구분자 == 이메일 잊지않고 마저 로그인 구현하겠습니다아 🤍
const LoginPage = () => { | ||
const { data: session } = useSession(); | ||
console.log(session?.accessToken); |
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.
useSession을 통해 accessToken
에 접근 가능합니다.
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.
전반적으로 차근히 훑어봤는데 꼼꼼하게 잘 해주신 것 같네요!
마저 애플로그인 관련 작업하면서 논의 필요한 부분은 바로바로 말씀드릴게요 👍
…feat/login-logo-ui-feature Feature/urdego#8: 로그인 UI로고 컴포넌트 구현, import 절대경로 세팅, 글로벌 컬러 세팅
#️⃣ 연관된 이슈
#7
📝 작업 내용
📸 스크린샷
💬 리뷰 요구사항
구현 완료한 사항
추가 구현에 인지해야 하는 사항
클라이언트에서 카카오 로그인 > accessToken 접근까지 완료했습니다. 이전에 논의한 백엔드에서 발급하는 jwt 토큰 발급 및 db에 저장된 사용자 정보 활용 방법을 찾아봤는데, 다음처럼 진행하면 될 것 같습니다.
프론트엔드
백엔드
프론트엔드