Skip to content

[Refactor/#160] Kakao Login 리팩토링 - #161

Merged
jyvnee merged 27 commits into
developfrom
refactor/#160-login
Jul 27, 2026
Merged

[Refactor/#160] Kakao Login 리팩토링#161
jyvnee merged 27 commits into
developfrom
refactor/#160-login

Conversation

@jyvnee

@jyvnee jyvnee commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Related issue 🛠️

Work Description ✏️

  • 카카오 로그인 로직을 KakaoLoginProvider, KakaoAuthClient, KakaoSdkAuthClient로 분리했습니다.
  • SocialLoginLauncher와 SocialLoginResult를 도입해 소셜 로그인 공통 구조를 구성했습니다.
  • 문자열 "KAKAO"를 SocialType.KAKAO로 변경했습니다.
  • 카카오 SDK 콜백을 suspend 함수로 변환하고 Coroutine 취소와 일반 실패를 분리했습니다.
  • 카카오톡 로그인 실패 시 카카오계정으로 전환하는 fallback 정책을 분리했습니다.
  • 사용자 취소, SDK 실패, 비정상 응답을 KakaoAuthResult로 명시적으로 구분했습니다.
  • 로그인 상태를 LoginPhase로 통합해 중복 클릭 및 중복 서버 요청을 방지했습니다.
  • 화면 Coroutine 취소 시 로그인 상태가 IDLE로 복구되도록 처리했습니다.
  • Compose 내부의 Hilt EntryPoint 접근을 제거하고 SocialLoginLauncher를 주입받도록 변경했습니다.
  • access token 전체를 출력하던 로그를 제거했습니다.
  • KakaoLoginProvider, DefaultSocialLoginLauncher, LoginViewModel 단위 테스트를 추가했습니다.

Screenshot 📸

N/A

Uncompleted Tasks 😅

  • Google 로그인 Provider 구현

To Reviewers 📢

  • 카카오톡 로그인 실패 시 사용자 취소를 제외한 오류는 카카오계정 로그인으로 fallback하도록 구성했습니다.
  • 로그인 상태는 IDLE → SOCIAL_LOGIN → SERVER_LOGIN → SUCCESS/FAILURE 순서로 전환됩니다.
  • 카카오톡 외부 앱 전환 중 Coroutine이 취소되지 않도록 로그인 Effect는 HandleSideEffects 대신 기존 LaunchedEffect 방식을 유지했습니다.
  • Google 로그인은 아직 미구현 상태이며, 현재 버튼 클릭 시 실패 처리되고 인증 없이 홈으로 이동하지 않습니다.
  • 추가한 인증 및 ViewModel 단위 테스트가 모두 통과하는 것을 확인했습니다.

Summary by CodeRabbit

  • 새로운 기능
    • 카카오 소셜 로그인 흐름을 공통 구조로 통합하고 성공/취소/실패를 일관되게 처리합니다.
    • 카카오톡 이용 불가/실패 시 카카오계정으로 자동 전환합니다.
    • 로그인 진행 중 중복 실행을 막고, 성공 시 신규/기존 사용자에 맞춰 온보딩/홈으로 이동합니다.
    • 구글은 동일한 구조로 준비되었으며(미구현), 시도 시 실패로 안내됩니다.
  • 버그 수정
    • 취소/중단 시 상태가 안정적으로 복구됩니다.
  • 테스트
    • 소셜 로그인 분기 및 로그인 상태 전환 단위 테스트를 추가/보강했습니다.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 05d0939e-2501-45a6-8822-f9bb89a32642

📥 Commits

Reviewing files that changed from the base of the PR and between dc12b3d and 3f6d7cd.

📒 Files selected for processing (1)
  • app/src/main/java/com/poti/android/presentation/auth/LoginScreen.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/main/java/com/poti/android/presentation/auth/LoginScreen.kt

📝 Walkthrough

Walkthrough

카카오 전용 로그인 흐름을 SocialLoginLauncher 기반의 공통 소셜 로그인 구조로 변경했습니다. 카카오 SDK 연동, 단계 기반 상태 관리, Hilt 전달 경로, Compose 버튼 상태 처리와 단위 테스트를 추가했습니다.

Changes

소셜 로그인 리팩터링

Layer / File(s) Summary
소셜 로그인 계약과 카카오 제공자
app/src/main/java/com/poti/android/core/auth/*, app/src/main/java/com/poti/android/data/auth/*
소셜 로그인 결과 계약과 카카오 SDK 연동을 추가하고, 카카오톡 로그인 및 계정 로그인 폴백을 코루틴 흐름으로 처리합니다.
소셜 타입과 서버 로그인 계약
app/src/main/java/com/poti/android/domain/..., app/src/main/java/com/poti/android/data/repository/AuthRepositoryImpl.kt, app/src/main/java/com/poti/android/data/local/datasource/PreferenceDataSource.kt
SocialType을 로그인 계약과 서버 요청에 적용하고 액세스 토큰 저장 로그를 제거했습니다.
로그인 상태와 ViewModel 흐름
app/src/main/java/com/poti/android/presentation/auth/model/*, app/src/main/java/com/poti/android/presentation/auth/LoginViewModel.kt
LoginPhase 기반 상태와 공통 소셜 로그인 인텐트·이펙트를 추가하고 서버 로그인 및 내비게이션을 처리합니다.
로그인 UI와 의존성 연결
app/src/main/java/com/poti/android/presentation/auth/*, app/src/main/java/com/poti/android/presentation/main/*, app/src/main/java/com/poti/android/data/di/*
로그인 화면을 런처 기반으로 변경하고 진행 중 버튼 비활성화 및 Hilt 의존성 전달을 연결했습니다.
로그인 흐름 테스트와 테스트 환경
app/src/test/java/com/poti/android/..., app/build.gradle.kts, gradle/libs.versions.toml
Mockito·코루틴 테스트 의존성과 디스패처 규칙을 추가하고 주요 로그인 흐름을 검증했습니다.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant LoginScreen
  participant LoginViewModel
  participant SocialLoginLauncher
  participant KakaoLoginProvider
  User->>LoginScreen: 소셜 로그인 버튼 클릭
  LoginScreen->>LoginViewModel: OnSocialLoginClick 전달
  LoginViewModel-->>LoginScreen: LaunchSocialLogin 효과
  LoginScreen->>SocialLoginLauncher: login(context, socialType)
  SocialLoginLauncher->>KakaoLoginProvider: 카카오 로그인 요청
  KakaoLoginProvider-->>LoginScreen: SocialLoginResult 전달
  LoginScreen->>LoginViewModel: OnSocialLoginResult 전달
  LoginViewModel-->>LoginScreen: 서버 로그인 및 내비게이션 효과
Loading

Suggested reviewers: cmj7271, doyeon0307

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 카카오 로그인 리팩토링이라는 핵심 변경을 정확하고 간결하게 요약합니다.
Description check ✅ Passed Related issue, Work Description, Screenshot, Uncompleted Tasks, To Reviewers가 모두 있어 템플릿을 대부분 충족합니다.
Linked Issues check ✅ Passed 직접 이슈 #160의 로그인 로직 리팩토링 목표를 카카오 로그인 구조 개편으로 충실히 반영했습니다.
Out of Scope Changes check ✅ Passed 테스트 추가, DI 연결, 상태 전환, 로그 제거 등은 모두 소셜/카카오 로그인 리팩토링 범위 안에 있습니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#160-login

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (5)
app/src/test/java/com/poti/android/presentation/auth/LoginViewModelTest.kt (1)

166-171: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

userAuth 헬퍼가 중복 정의되어 있습니다.

동일한 로직의 userAuth(isNewUser: Boolean)가 outer 클래스 멤버(Line 166-171)와 companion object(Line 206-211) 양쪽에 정의되어 있습니다. FakeAuthRepositoryinner class가 아니라 outer 인스턴스 멤버에 접근할 수 없어 companion에도 복사본을 둔 것으로 보이는데, companion 멤버는 outer 클래스 본문에서 별도 한정자 없이도 접근 가능하므로 Line 166-171의 인스턴스 멤버는 불필요합니다. 하나만 남기면 두 구현이 어긋날 위험도 없어집니다.

♻️ 제안하는 수정
-    private fun userAuth(isNewUser: Boolean) = UserAuth(
-        accessToken = SERVER_ACCESS_TOKEN,
-        refreshToken = SERVER_REFRESH_TOKEN,
-        isNewUser = isNewUser,
-        userId = USER_ID,
-    )
-
     private class FakeAuthRepository : AuthRepository {

CompanionuserAuth는 그대로 두면 outer 클래스의 다른 테스트 메서드(Line 124, 138)에서도 한정자 없이 그대로 호출됩니다.

Also applies to: 200-212

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/test/java/com/poti/android/presentation/auth/LoginViewModelTest.kt`
around lines 166 - 171, Remove the duplicate instance-level userAuth(isNewUser:
Boolean) helper from the outer test class, and retain the existing
Companion.userAuth implementation so both FakeAuthRepository and outer test
methods resolve to the single shared helper.
app/src/main/java/com/poti/android/data/repository/AuthRepositoryImpl.kt (1)

40-40: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

서버 전송값을 enum.name에 직접 의존하지 말아 주세요.

AuthService는 이 DTO를 /api/v1/auth/login으로 바로 전송하므로, 서버가 요구하는 값의 대소문자나 코드가 enum 식별자와 다르면 로그인 요청이 실패합니다. SocialType별 명시적인 wire value 또는 mapper를 사용하고, 서버 계약 테스트로 실제 값을 검증해 주세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/main/java/com/poti/android/data/repository/AuthRepositoryImpl.kt` at
line 40, Update AuthRepositoryImpl’s DTO mapping so socialType does not use
SocialType.name directly; define or reuse an explicit wire value/mapper for each
SocialType and send that value through AuthService. Add or update a
server-contract test to verify the exact values sent to /api/v1/auth/login.
app/src/main/java/com/poti/android/presentation/main/MainScreen.kt (1)

10-17: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Modifier를 외부에서 주입받도록 추가해 주세요.

현재 MainScreenModifier를 파라미터로 노출하지 않고 Scaffold에서 Modifier.fillMaxSize()를 고정합니다. modifier: Modifier = Modifiernavigator보다 앞에 추가하고 Scaffold에 적용해 주세요.

제안
 fun MainScreen(
     targetDestination: Route,
     socialLoginLauncher: SocialLoginLauncher,
+    modifier: Modifier = Modifier,
     navigator: MainNavigator = rememberPotiNavigator(),
 ) {
     Scaffold(
-        modifier = Modifier.fillMaxSize(),
+        modifier = modifier.fillMaxSize(),

As per path instructions: Modifier는 항상 컴포저블 함수의 첫 번째 선택적 파라미터로 받아야 하며, 재사용성을 위해 외부에서 주입받아야 합니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/main/java/com/poti/android/presentation/main/MainScreen.kt` around
lines 10 - 17, MainScreen의 파라미터에 modifier: Modifier = Modifier를 navigator보다 앞에
추가하고, Scaffold의 고정된 Modifier.fillMaxSize() 대신 주입받은 modifier를 적용하세요. 컴포저블 함수의 첫
번째 선택적 파라미터라는 기존 순서를 유지하면서 외부 Modifier 주입이 가능하도록 수정합니다.

Source: Path instructions

app/src/main/java/com/poti/android/presentation/auth/LoginScreen.kt (1)

83-88: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Modifier가 필수 파라미터보다 앞에 위치했어요.

Compose 공식 가이드라인상 modifier는 모든 필수 파라미터(트레일링 람다 제외) 다음, 다른 선택 파라미터보다 앞에 와야 해요. 여기선 필수값인 isLoginInProgress보다 modifier가 먼저 선언되어 있네요.

♻️ 제안하는 수정
 private fun LoginScreen(
-    modifier: Modifier = Modifier,
-    isLoginInProgress: Boolean,
+    isLoginInProgress: Boolean,
+    modifier: Modifier = Modifier,
     onKakaoClick: () -> Unit,
     onGoogleClick: () -> Unit,
 ) {

As per path instructions, "Modifier는 항상 컴포저블 함수의 첫 번째 선택적 파라미터로 받아야 하며".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/main/java/com/poti/android/presentation/auth/LoginScreen.kt` around
lines 83 - 88, Reorder the LoginScreen parameters so the required
isLoginInProgress parameter comes before the optional modifier parameter,
keeping modifier as the first optional parameter and leaving the callback
parameters unchanged.

Source: Path instructions

app/src/main/java/com/poti/android/presentation/auth/LoginViewModel.kt (1)

69-86: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

성공 분기에서 상태 업데이트 중복 제거를 제안드려요.

isNewUser 분기 양쪽에서 updateState { copy(phase = LoginPhase.SUCCESS) }가 똑같이 반복되고 있어요. 분기 밖으로 빼면 DRY 원칙에도 맞고 가독성도 좋아질 것 같아요.

♻️ 제안하는 리팩터
             .onSuccess { response ->
+                updateState { copy(phase = LoginPhase.SUCCESS) }
                 if (response.isNewUser) {
                     Timber.i("신규 회원입니다. 온보딩 상태: 미완료(false)로 저장 -> 온보딩으로 이동")
-                    updateState { copy(phase = LoginPhase.SUCCESS) }
                     sendEffect(LoginEffect.NavigateToOnboarding)
                 } else {
                     Timber.i("기존 회원입니다. 온보딩 상태: 완료(true)로 저장 -> 홈으로 이동")
-                    updateState { copy(phase = LoginPhase.SUCCESS) }
                     sendEffect(LoginEffect.NavigateToHome)
                 }
             }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/main/java/com/poti/android/presentation/auth/LoginViewModel.kt`
around lines 69 - 86, In the success handling of the login flow, move the shared
updateState call that sets LoginPhase.SUCCESS outside the response.isNewUser
conditional. Keep each branch’s logging and navigation effect unchanged, with
the state update executed once before selecting the destination.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/src/main/java/com/poti/android/data/auth/KakaoLoginProvider.kt`:
- Around line 38-46: Update the login flow around awaitLogin, startLogin, and
loginWithKakaoAccount to propagate the awaitLogin continuation’s active state.
Check that state before starting the Kakao account fallback and in each
authentication callback, preventing any result delivery or browser UI launch
after cancellation.

In `@app/src/main/java/com/poti/android/data/auth/KakaoSdkAuthClient.kt`:
- Around line 48-55: Update the result mapping in KakaoSdkAuthClient’s callback
so error handling precedes accessToken handling. Preserve the
ClientErrorCause.Cancelled mapping to KakaoAuthResult.Cancelled, map all other
non-null errors to Failure, and only then return Success for a non-null,
non-empty token; map null or blank tokens to InvalidResponse.

In `@app/src/main/java/com/poti/android/presentation/auth/LoginScreen.kt`:
- Around line 52-65: Update the LaunchSocialLogin handling around
socialLoginLauncher.login in the LoginScreen flow to catch non-cancellation
exceptions and convert them into the existing SocialLoginResult.Failure
representation before dispatching OnSocialLoginResult. Preserve the current
OnSocialLoginAborted behavior and rethrow CancellationException so coroutine
cancellation remains intact.

---

Nitpick comments:
In `@app/src/main/java/com/poti/android/data/repository/AuthRepositoryImpl.kt`:
- Line 40: Update AuthRepositoryImpl’s DTO mapping so socialType does not use
SocialType.name directly; define or reuse an explicit wire value/mapper for each
SocialType and send that value through AuthService. Add or update a
server-contract test to verify the exact values sent to /api/v1/auth/login.

In `@app/src/main/java/com/poti/android/presentation/auth/LoginScreen.kt`:
- Around line 83-88: Reorder the LoginScreen parameters so the required
isLoginInProgress parameter comes before the optional modifier parameter,
keeping modifier as the first optional parameter and leaving the callback
parameters unchanged.

In `@app/src/main/java/com/poti/android/presentation/auth/LoginViewModel.kt`:
- Around line 69-86: In the success handling of the login flow, move the shared
updateState call that sets LoginPhase.SUCCESS outside the response.isNewUser
conditional. Keep each branch’s logging and navigation effect unchanged, with
the state update executed once before selecting the destination.

In `@app/src/main/java/com/poti/android/presentation/main/MainScreen.kt`:
- Around line 10-17: MainScreen의 파라미터에 modifier: Modifier = Modifier를
navigator보다 앞에 추가하고, Scaffold의 고정된 Modifier.fillMaxSize() 대신 주입받은 modifier를
적용하세요. 컴포저블 함수의 첫 번째 선택적 파라미터라는 기존 순서를 유지하면서 외부 Modifier 주입이 가능하도록 수정합니다.

In `@app/src/test/java/com/poti/android/presentation/auth/LoginViewModelTest.kt`:
- Around line 166-171: Remove the duplicate instance-level userAuth(isNewUser:
Boolean) helper from the outer test class, and retain the existing
Companion.userAuth implementation so both FakeAuthRepository and outer test
methods resolve to the single shared helper.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 04fed822-9779-46c4-9635-04018ba64525

📥 Commits

Reviewing files that changed from the base of the PR and between 06da0dd and 924b8aa.

📒 Files selected for processing (29)
  • app/build.gradle.kts
  • app/src/main/java/com/poti/android/core/auth/SocialLoginLauncher.kt
  • app/src/main/java/com/poti/android/core/auth/SocialLoginResult.kt
  • app/src/main/java/com/poti/android/data/auth/DefaultSocialLoginLauncher.kt
  • app/src/main/java/com/poti/android/data/auth/KakaoAuthClient.kt
  • app/src/main/java/com/poti/android/data/auth/KakaoAuthResult.kt
  • app/src/main/java/com/poti/android/data/auth/KakaoLoginProvider.kt
  • app/src/main/java/com/poti/android/data/auth/KakaoSdkAuthClient.kt
  • app/src/main/java/com/poti/android/data/di/SocialAuthModule.kt
  • app/src/main/java/com/poti/android/data/local/datasource/PreferenceDataSource.kt
  • app/src/main/java/com/poti/android/data/repository/AuthRepositoryImpl.kt
  • app/src/main/java/com/poti/android/domain/model/auth/SocialType.kt
  • app/src/main/java/com/poti/android/domain/repository/AuthRepository.kt
  • app/src/main/java/com/poti/android/domain/usecase/auth/LoginUseCase.kt
  • app/src/main/java/com/poti/android/presentation/auth/KakaoLoginManager.kt
  • app/src/main/java/com/poti/android/presentation/auth/LoginScreen.kt
  • app/src/main/java/com/poti/android/presentation/auth/LoginViewModel.kt
  • app/src/main/java/com/poti/android/presentation/auth/component/LoginButton.kt
  • app/src/main/java/com/poti/android/presentation/auth/model/Contracts.kt
  • app/src/main/java/com/poti/android/presentation/auth/model/LoginPhase.kt
  • app/src/main/java/com/poti/android/presentation/auth/navigation/AuthNavigation.kt
  • app/src/main/java/com/poti/android/presentation/main/MainActivity.kt
  • app/src/main/java/com/poti/android/presentation/main/MainNavHost.kt
  • app/src/main/java/com/poti/android/presentation/main/MainScreen.kt
  • app/src/test/java/com/poti/android/MainDispatcherRule.kt
  • app/src/test/java/com/poti/android/data/auth/DefaultSocialLoginLauncherTest.kt
  • app/src/test/java/com/poti/android/data/auth/KakaoLoginProviderTest.kt
  • app/src/test/java/com/poti/android/presentation/auth/LoginViewModelTest.kt
  • gradle/libs.versions.toml
💤 Files with no reviewable changes (2)
  • app/src/main/java/com/poti/android/presentation/auth/KakaoLoginManager.kt
  • app/src/main/java/com/poti/android/data/local/datasource/PreferenceDataSource.kt

Comment thread app/src/main/java/com/poti/android/data/auth/KakaoLoginProvider.kt Outdated
Comment thread app/src/main/java/com/poti/android/data/auth/KakaoSdkAuthClient.kt
Comment thread app/src/main/java/com/poti/android/presentation/auth/LoginScreen.kt
@jyvnee
jyvnee requested review from cmj7271 and doyeon0307 July 23, 2026 06:09

@doyeon0307 doyeon0307 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

짱짱!!

Comment on lines +54 to +56
if (result.shouldFallbackToKakaoAccount()) {
loginWithKakaoAccount(context, isActive, onResult)
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p2 : result.shouldFallbackToKakaoAccounttrue 고정이어서 카톡 로그인 실패 시에 항상 loginWithKakaoAccount로 넘아가게 되는데,
그러면 loginWithKakaoAccount의 결과만 남고 카톡 로그인의 실패 원인은 추적이 안되는 것 같아요.
이 지점에서 로그라도 심어주면 어떨까요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가했습니다!

}
}

private fun KakaoAuthResult.Failure.shouldFallbackToKakaoAccount(): Boolean = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p2 : 여기 never used로 뜨네요!!

Suggested change
private fun KakaoAuthResult.Failure.shouldFallbackToKakaoAccount(): Boolean = true
private fun shouldFallbackToKakaoAccount(): Boolean = true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldFallbackToKakaoAccount 함수를 사용하지 않고 KakaoAuthResult.Failure로 분기처리 하도록 수정했습니다!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/src/test/java/com/poti/android/data/auth/KakaoLoginProviderTest.kt`:
- Around line 77-93: Replace the scheduling-dependent yield() in the
cancellation test with explicit synchronization using a CompletableDeferred or
equivalent signal from DeferredKakaoAuthClient when loginWithKakaoTalk is
entered and its callback is registered. Await that signal before cancelAndJoin,
then complete the KakaoTalk login and preserve the assertions that fallback is
not started.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 31710d8a-ef8d-46ee-90a7-1ece67cc4178

📥 Commits

Reviewing files that changed from the base of the PR and between 924b8aa and dc12b3d.

📒 Files selected for processing (4)
  • app/src/main/java/com/poti/android/data/auth/KakaoLoginProvider.kt
  • app/src/main/java/com/poti/android/data/auth/KakaoSdkAuthClient.kt
  • app/src/main/java/com/poti/android/presentation/auth/LoginScreen.kt
  • app/src/test/java/com/poti/android/data/auth/KakaoLoginProviderTest.kt
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/src/main/java/com/poti/android/presentation/auth/LoginScreen.kt
  • app/src/main/java/com/poti/android/data/auth/KakaoSdkAuthClient.kt

Comment on lines +77 to +93
@Test
fun `does not start fallback after login coroutine is cancelled`() = runBlocking {
val client = DeferredKakaoAuthClient()
val provider = KakaoLoginProvider(client)
val loginJob = launch {
provider.login(context)
}
yield()

loginJob.cancelAndJoin()
client.completeKakaoTalkLogin(
KakaoAuthResult.Failure(RuntimeException("talk login failed")),
)

assertEquals(1, client.kakaoTalkLoginCallCount)
assertEquals(0, client.kakaoAccountLoginCallCount)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

yield() 대신 로그인 시작을 명시적으로 동기화해 주세요.

yield()만으로는 kakaoTalkCallback 등록이 완료됐음을 보장하지 않습니다. 스케줄링에 따라 Line 87에서 requireNotNull이 실패해 테스트가 간헐적으로 깨질 수 있습니다. CompletableDeferred 등으로 loginWithKakaoTalk 진입을 대기한 뒤 취소해 주세요.

수정 예시
+import kotlinx.coroutines.CompletableDeferred
+import kotlinx.coroutines.awaitAll

-        yield()
+        client.kakaoTalkLoginStarted.await()

     private class DeferredKakaoAuthClient : KakaoAuthClient {
+        val kakaoTalkLoginStarted = CompletableDeferred<Unit>()
         private var kakaoTalkCallback: ((KakaoAuthResult) -> Unit)? = null

         override fun loginWithKakaoTalk(
             context: Context,
             onResult: (KakaoAuthResult) -> Unit,
         ) {
             kakaoTalkLoginCallCount += 1
             kakaoTalkCallback = onResult
+            kakaoTalkLoginStarted.complete(Unit)
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/test/java/com/poti/android/data/auth/KakaoLoginProviderTest.kt`
around lines 77 - 93, Replace the scheduling-dependent yield() in the
cancellation test with explicit synchronization using a CompletableDeferred or
equivalent signal from DeferredKakaoAuthClient when loginWithKakaoTalk is
entered and its callback is registered. Await that signal before cancelAndJoin,
then complete the KakaoTalk login and preserve the assertions that fallback is
not started.

@cmj7271 cmj7271 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생 많으셨습니닷


@Composable
private fun LoginScreen(
modifier: Modifier = Modifier,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3: 소소하지만 modifier 가 맨앞에 있네요

@jyvnee
jyvnee merged commit 3e22cfe into develop Jul 27, 2026
2 checks passed
@jyvnee
jyvnee deleted the refactor/#160-login branch July 27, 2026 00:08
@github-project-automation github-project-automation Bot moved this from To-do to Done in POTI-ANDROID Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Refactor] 카카오 로그인 리팩토링

3 participants