-
Notifications
You must be signed in to change notification settings - Fork 1
[Feature/#5] 카카오 소셜 로그인 구현 #14
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d8a8316
Feat: 카카오 SDK 연동
wjdrjs00 a623843
Feat: 로그인 화면 MVI 모델 정의
wjdrjs00 49e6c78
Feat: 카카오 로그인 기능 추가
wjdrjs00 c52938e
Refactor: local.properties 파일 처리 방식 변경
wjdrjs00 1ba7b83
Feat: CI 환경에서 카카오 로그인 키 설정
wjdrjs00 679e736
Fix: generate local.properties task 위치 변경
wjdrjs00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/threegap/bitnagil/BitnagilApplication.kt
This file contains hidden or 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,11 +1,17 @@ | ||
| package com.threegap.bitnagil | ||
|
|
||
| import android.app.Application | ||
| import com.kakao.sdk.common.KakaoSdk | ||
| import dagger.hilt.android.HiltAndroidApp | ||
|
|
||
| @HiltAndroidApp | ||
| class BitnagilApplication : Application() { | ||
| override fun onCreate() { | ||
| super.onCreate() | ||
| initKakaoSdk() | ||
| } | ||
|
|
||
| private fun initKakaoSdk() { | ||
| KakaoSdk.init(this, BuildConfig.KAKAO_NATIVE_APP_KEY) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
68 changes: 68 additions & 0 deletions
68
presentation/src/main/java/com/threegap/bitnagil/presentation/login/LoginViewModel.kt
This file contains hidden or 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,68 @@ | ||
| package com.threegap.bitnagil.presentation.login | ||
|
|
||
| import android.util.Log | ||
| import androidx.lifecycle.SavedStateHandle | ||
| import com.kakao.sdk.common.model.ClientError | ||
| import com.kakao.sdk.common.model.ClientErrorCause | ||
| import com.kakao.sdk.user.UserApiClient | ||
| import com.threegap.bitnagil.presentation.common.mviviewmodel.MviViewModel | ||
| import com.threegap.bitnagil.presentation.login.model.LoginIntent | ||
| import com.threegap.bitnagil.presentation.login.model.LoginSideEffect | ||
| import com.threegap.bitnagil.presentation.login.model.LoginState | ||
| import dagger.hilt.android.lifecycle.HiltViewModel | ||
| import org.orbitmvi.orbit.syntax.simple.SimpleSyntax | ||
| import javax.inject.Inject | ||
|
|
||
| @HiltViewModel | ||
| class LoginViewModel | ||
| @Inject | ||
| constructor( | ||
| private val savedStateHandle: SavedStateHandle, | ||
| ) : MviViewModel<LoginState, LoginSideEffect, LoginIntent>( | ||
| initState = LoginState(), | ||
| savedStateHandle = savedStateHandle, | ||
| ) { | ||
| override suspend fun SimpleSyntax<LoginState, LoginSideEffect>.reduceState( | ||
| intent: LoginIntent, | ||
| state: LoginState, | ||
| ): LoginState? = | ||
| when (intent) { | ||
| is LoginIntent.OnKakaoLoginClick -> { | ||
| if (!intent.onKakaoTalkLoginAvailable) { | ||
| sendSideEffect(LoginSideEffect.RequestKakaoAccountLogin) | ||
| } else { | ||
| sendSideEffect(LoginSideEffect.RequestKakaoTalkLogin) | ||
| } | ||
| null | ||
| } | ||
|
|
||
| is LoginIntent.OnKakaoLoginResult -> { | ||
| when { | ||
| intent.token != null -> { | ||
| Log.i("KakaoLogin", "로그인 성공 ${intent.token.accessToken}") | ||
| UserApiClient.instance.me { user, error -> | ||
| if (error != null) { | ||
| Log.e("KakaoLogin", "사용자 정보 요청 실패", error) | ||
| } else if (user != null) { | ||
| Log.i( | ||
| "KakaoLogin", | ||
| "사용자 정보 요청 성공" + | ||
| "\n이메일: ${user.kakaoAccount?.email}" + | ||
| "\n닉네임: ${user.kakaoAccount?.profile?.nickname}", | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| intent.error is ClientError && intent.error.reason == ClientErrorCause.Cancelled -> { | ||
| Log.e("KakaoLogin", "로그인 취소", intent.error) | ||
| } | ||
|
|
||
| intent.error != null -> { | ||
| Log.e("KakaoLogin", "로그인 실패", intent.error) | ||
|
l5x5l marked this conversation as resolved.
|
||
| } | ||
| } | ||
| null | ||
| } | ||
|
l5x5l marked this conversation as resolved.
|
||
| } | ||
| } | ||
13 changes: 13 additions & 0 deletions
13
presentation/src/main/java/com/threegap/bitnagil/presentation/login/model/LoginIntent.kt
This file contains hidden or 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,13 @@ | ||
| package com.threegap.bitnagil.presentation.login.model | ||
|
|
||
| import com.kakao.sdk.auth.model.OAuthToken | ||
| import com.threegap.bitnagil.presentation.common.mviviewmodel.MviIntent | ||
|
|
||
| sealed class LoginIntent : MviIntent { | ||
| data class OnKakaoLoginClick(val onKakaoTalkLoginAvailable: Boolean) : LoginIntent() | ||
|
|
||
| data class OnKakaoLoginResult( | ||
| val token: OAuthToken?, | ||
| val error: Throwable?, | ||
| ) : LoginIntent() | ||
| } |
9 changes: 9 additions & 0 deletions
9
presentation/src/main/java/com/threegap/bitnagil/presentation/login/model/LoginSideEffect.kt
This file contains hidden or 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,9 @@ | ||
| package com.threegap.bitnagil.presentation.login.model | ||
|
|
||
| import com.threegap.bitnagil.presentation.common.mviviewmodel.MviSideEffect | ||
|
|
||
| sealed interface LoginSideEffect : MviSideEffect { | ||
| data object RequestKakaoTalkLogin : LoginSideEffect | ||
|
|
||
| data object RequestKakaoAccountLogin : LoginSideEffect | ||
| } |
9 changes: 9 additions & 0 deletions
9
presentation/src/main/java/com/threegap/bitnagil/presentation/login/model/LoginState.kt
This file contains hidden or 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,9 @@ | ||
| package com.threegap.bitnagil.presentation.login.model | ||
|
|
||
| import com.threegap.bitnagil.presentation.common.mviviewmodel.MviState | ||
| import kotlinx.parcelize.Parcelize | ||
|
|
||
| @Parcelize | ||
| data class LoginState( | ||
| val isLoggedIn: Boolean = false, | ||
| ) : MviState |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.