Skip to content

[#302] FCM토큰이 유효하지 않을 때, 에러가 뜨고 로컬 세션이 유지되는 이슈를 해결한다#303

Merged
opficdev merged 3 commits intodevelopfrom
fix/#302-invalid-fcm-token
Mar 19, 2026
Merged

[#302] FCM토큰이 유효하지 않을 때, 에러가 뜨고 로컬 세션이 유지되는 이슈를 해결한다#303
opficdev merged 3 commits intodevelopfrom
fix/#302-invalid-fcm-token

Conversation

@opficdev
Copy link
Owner

@opficdev opficdev self-assigned this Mar 19, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 FCM 토큰이 유효하지 않을 때 로컬 세션이 유지되고 오류가 발생하는 문제를 해결합니다. 애플리케이션의 인증 세션 관리를 대폭 리팩토링하여, 인증 상태 처리를 Combine 퍼블리셔를 사용하는 AuthService 내에서 중앙화하고, 리포지토리 및 유스케이스의 중복된 세션 관리 로직을 제거했습니다. 또한, 모든 '초기 실행' 관련 로직을 제거하여 애플리케이션의 초기 상태를 단순화하고 복잡성을 줄였습니다. 로그아웃 프로세스도 개선하여 인증 오류 발생 시에도 완전한 세션 정리가 보장됩니다.

Highlights

  • 인증 세션 관리 리팩토링: AuthSessionRepository와 AuthSessionUseCase가 더 이상 signIn 상태를 직접 관리하거나 UserDefaultsStore를 지우지 않습니다. 대신, AuthService가 Combine과 AuthStateDidChangeListenerHandle을 사용하여 로그인 상태를 직접 발행하도록 변경하여 인증 상태 관리를 중앙화했습니다.
  • 초기 실행(First Launch) 로직 제거: FetchFirstLaunchUseCase, UpdateFirstLaunchUseCase 및 관련 구현체, UserPreferencesRepository와 RootViewModel의 isFirstLaunch 속성 등 초기 실행과 관련된 모든 로직이 제거되어 앱의 초기 설정 및 상태 관리가 간소화되었습니다.
  • 로그아웃 오류 처리 개선: AuthenticationRepositoryImpl에서 getProviderID()가 실패하거나 소셜 로그아웃(Apple, GitHub, Google) 시 AuthError.notAuthenticated 오류가 발생할 경우 authService.clearCurrentSession()을 명시적으로 호출하여 오류 상황에서도 깔끔한 로그아웃을 보장합니다.
  • ViewModel 의존성 간소화: LoginViewModel, RootViewModel, SettingViewModel에서 signOutUseCase, sessionUseCase 및 초기 실행 관련 유스케이스에 대한 의존성이 제거되어 각 ViewModel의 책임이 명확해지고 코드가 간결해졌습니다.
  • UserDefaultsStore.removeAll() 제거: isFirstLaunch를 제외하고 사용자 기본 설정을 선택적으로 지우던 UserDefaultsStore의 removeAll() 메서드가 제거되어 초기 실행 개념 제거와 일관성을 유지합니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

이 PR은 인증 및 세션 관리 로직을 크게 리팩토링하여 FCM 토큰이 유효하지 않을 때 로컬 세션이 유지되는 문제를 해결합니다. AuthService에 Firebase의 addStateDidChangeListener를 사용하여 인증 상태 관리를 중앙집중화한 점이 인상적입니다. 이로 인해 AuthService가 인증 상태의 단일 진실 공급원(Single Source of Truth)이 되어, 여러 ViewModel과 Repository에서 수동으로 세션 상태를 관리할 필요가 없어졌습니다. 코드의 복잡성이 줄고 안정성이 향상되었습니다. 또한, 문제가 되었던 '첫 실행' 관련 로직을 제거하여 초기 앱 흐름을 단순화한 점도 좋은 개선입니다. 전반적으로 아키텍처를 개선하고 버그를 수정한 훌륭한 변경입니다.

private let messaging = Messaging.messaging()
private let logger = Logger(category: "AuthService")
private let subject = CurrentValueSubject<Bool, Never>(Auth.auth().currentUser != nil)
private var handler: AuthStateDidChangeListenerHandle?
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

handler 속성은 init 초기화 시에만 값이 할당되고 이후에는 변경되지 않습니다. var 대신 let으로 선언하여 불변성(immutability)을 보장하는 것이 더 안전하고 명확한 코드가 될 것입니다.

Suggested change
private var handler: AuthStateDidChangeListenerHandle?
private let handler: AuthStateDidChangeListenerHandle?

@opficdev opficdev added the qa TestFlight에 배포 label Mar 19, 2026
@opficdev opficdev merged commit fae35af into develop Mar 19, 2026
2 checks passed
@opficdev opficdev deleted the fix/#302-invalid-fcm-token branch March 19, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qa TestFlight에 배포

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FCM토큰이 유효하지 않을 때, 에러가 뜨고 로컬 세션이 유지되는 이슈를 해결한다

1 participant