feat : Naver 로그인 타입 추가

This commit is contained in:
banjjoknim
2022-03-08 12:52:58 +09:00
parent a62fbb7f71
commit 5891775b15
2 changed files with 31 additions and 2 deletions

View File

@@ -5,7 +5,8 @@ enum class OAuth2Type(
private val createUserInfo: (attributes: Map<String, Any?>) -> OAuth2UserInfo
) {
GOOGLE("google", { attributes -> GoogleUserInfo(attributes) }),
FACEBOOK("facebook", { attributes -> FacebookUserInfo(attributes) });
FACEBOOK("facebook", { attributes -> FacebookUserInfo(attributes) }),
NAVER("naver", { attributes -> NaverUserInfo(attributes) });
fun createOAuth2UserInfo(attributes: Map<String, Any?>): OAuth2UserInfo {
return createUserInfo(attributes)

View File

@@ -53,5 +53,33 @@ class FacebookUserInfo(
override fun getName(): String {
return attributes["name"] as String
}
}
class NaverUserInfo(
/**
* DefaultOAuth2Service#loadUser(OAuth2UserRequest)
* ```kotlin
* val oAuth2User = super.loadUser(userRequest)
* val attributes = oAuth2User.attributes
* ```
*/
private val attributes: Map<String, Any?>
): OAuth2UserInfo {
private val response = attributes["response"] as Map<*, *>
override fun getProviderId(): String {
return response["id"] as String
}
override fun getProvider(): String {
return "naver"
}
override fun getEmail(): String {
return response["email"] as String
}
override fun getName(): String {
return response["name"] as String
}
}