-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
130 additions
and
3 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
16 changes: 16 additions & 0 deletions
16
core/design-system/src/main/res/drawable/ic_logo_kakao.xml
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,16 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="19dp" | ||
android:height="19dp" | ||
android:viewportWidth="19" | ||
android:viewportHeight="19"> | ||
<group> | ||
<clip-path | ||
android:pathData="M0.5,0.5h18v18h-18z"/> | ||
<path | ||
android:pathData="M9.5,1.443C4.79,1.443 0.5,5.229 0.5,8.432C0.5,10.832 2.058,12.949 4.431,14.207L3.433,17.873C3.344,18.198 3.713,18.456 3.996,18.269L8.373,15.364C8.742,15.4 9.118,15.421 9.5,15.421C14.47,15.421 18.5,12.292 18.5,8.432C18.5,5.229 14.47,1.443 9.5,1.443Z" | ||
android:strokeAlpha="0.902" | ||
android:fillColor="#000000" | ||
android:fillType="evenOdd" | ||
android:fillAlpha="0.902"/> | ||
</group> | ||
</vector> |
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
67 changes: 67 additions & 0 deletions
67
data/auth/src/main/java/com/easyhz/noffice/data/auth/strategy/KakaoStrategy.kt
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,67 @@ | ||
package com.easyhz.noffice.data.auth.strategy | ||
|
||
import android.content.Context | ||
import android.util.Log | ||
import com.kakao.sdk.auth.model.OAuthToken | ||
import com.kakao.sdk.common.model.ClientError | ||
import com.kakao.sdk.common.model.ClientErrorCause | ||
import com.kakao.sdk.user.UserApiClient | ||
import kotlinx.coroutines.suspendCancellableCoroutine | ||
import javax.inject.Inject | ||
import kotlin.coroutines.resume | ||
import kotlin.coroutines.resumeWithException | ||
|
||
class KakaoStrategy @Inject constructor() : BaseStrategy() { | ||
private val tag = this.javaClass.name | ||
override suspend fun login(context: Context): Result<String> = runCatching { | ||
val token = loginWithKakaoTalk(context) | ||
Log.d(tag, "카카오톡으로 로그인 성공 ${token.accessToken}") | ||
token.accessToken | ||
}.recoverCatching { error -> | ||
Log.d(tag, "카카오톡으로 로그인 실패 : $error") | ||
|
||
if (error is ClientError && error.reason == ClientErrorCause.Cancelled) throw error // 의도적인 로그인 취소 | ||
|
||
val token = loginWithKakaoAccount(context) | ||
Log.d(tag, "카카오 계정으로 로그인 성공 ${token.accessToken}") | ||
token.accessToken | ||
} | ||
|
||
override suspend fun logout(context: Context): Result<Unit> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
/** | ||
* 카카오톡으로 로그인 | ||
* | ||
* @param context Context | ||
* @return [OAuthToken] 로그인 성공 시 발급되는 토큰 | ||
*/ | ||
private suspend fun loginWithKakaoTalk(context: Context): OAuthToken = suspendCancellableCoroutine { continuation -> | ||
UserApiClient.instance.loginWithKakaoTalk(context) { token, error -> | ||
when { | ||
error != null -> continuation.resumeWithException(error) | ||
token != null -> continuation.resume(token) | ||
else -> continuation.resumeWithException(IllegalStateException("Unexpected error during KakaoTalk login")) | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* 카카오 계정으로 로그인 | ||
* | ||
* * 카카오톡에 연결된 카카오 계정이 없을 경우 카카오 계정 로그인 시도 | ||
* | ||
* @param context Context | ||
* @return [OAuthToken] 로그인 성공 시 발급되는 토큰 | ||
*/ | ||
private suspend fun loginWithKakaoAccount(context: Context): OAuthToken = suspendCancellableCoroutine { continuation -> | ||
UserApiClient.instance.loginWithKakaoAccount(context) { token, error -> | ||
when { | ||
error != null -> continuation.resumeWithException(error) | ||
token != null -> continuation.resume(token) | ||
else -> continuation.resumeWithException(IllegalStateException("Unexpected error during KakaoAccount login")) | ||
} | ||
} | ||
} | ||
} |
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