fix: user not found error at first signin#605
Conversation
📝 WalkthroughWalkthrough토큰 기반 로그인 엔드포인트가 추가되었고, Retrofit 주석(@get, @query)으로 통합되었습니다. BaseAuthApi에 login 메서드가 도입되었으며, User/Auth API 구현에 해당 메서드가 추가되었습니다. RestAuthRepository.login() 흐름에 액세스 토큰 저장 후 _api.login(accessToken) 호출이 삽입되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant App as App UI
participant Repo as RestAuthRepository
participant OAuth as OAuth Provider
participant Storage as Token Storage
participant API as Auth/User API
participant Server as Backend
User->>App: 로그인 요청
App->>Repo: login(credentials)
Repo->>OAuth: 토큰 발급 요청
OAuth-->>Repo: accessToken (+ refreshToken)
Repo->>Storage: 토큰 저장
Repo->>API: login(accessToken as query)
API->>Server: GET /login?token=accessToken
Server-->>API: 200 OK
API-->>Repo: 완료
Repo-->>App: 로그인 완료
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
lib/app/modules/auth/data/data_sources/remote/base_auth_api.dart (1)
4-4: 반환 타입의 일관성을 확인해주세요.베이스 클래스에서는 제네릭
Future를 사용하고 있지만, 구현체들에서는Future<void>를 사용하고 있습니다. 일관성을 위해 베이스 클래스도Future<void>로 변경하는 것을 고려해보세요.- Future login(@Query('token') String token); + Future<void> login(@Query('token') String token);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
lib/app/modules/auth/data/data_sources/remote/base_auth_api.dart(1 hunks)lib/app/modules/user/data/data_sources/remote/auth_api.dart(1 hunks)lib/app/modules/user/data/data_sources/remote/user_api.dart(1 hunks)lib/app/modules/user/data/repositories/rest_auth_repository.dart(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build Android App and Test
- GitHub Check: Build iOS App and Test
🔇 Additional comments (3)
lib/app/modules/user/data/data_sources/remote/auth_api.dart (1)
16-18: 새로운 로그인 엔드포인트가 올바르게 구현되었습니다.베이스 API의 메서드를 적절히 오버라이드했으며, Retrofit 어노테이션도 정확합니다. 반환 타입도
Future<void>로 명확하게 정의되어 있습니다.lib/app/modules/auth/data/data_sources/remote/base_auth_api.dart (1)
1-1: Retrofit 통합을 위한 import가 추가되었습니다.새로운 로그인 메서드의
@Query어노테이션을 위해 필요한 import입니다.lib/app/modules/user/data/data_sources/remote/user_api.dart (1)
16-18: UserApi의 로그인 엔드포인트가 올바르게 구현되었습니다.베이스 API를 적절히 오버라이드했으며, Retrofit 어노테이션과 쿼리 파라미터 설정이 정확합니다.
| if (token.refreshToken != null) { | ||
| await _tokenRepository.saveRefreshToken(token.refreshToken!); | ||
| } | ||
| await _api.login(token.accessToken); |
There was a problem hiding this comment.
새로운 API 호출에 대한 에러 핸들링을 추가해주세요.
토큰 저장 후 추가된 _api.login(token.accessToken) 호출이 실패할 경우를 대비한 에러 핸들링이 필요합니다. 이 호출이 실패하더라도 사용자가 로그인 상태를 유지할 수 있도록 처리하거나, 실패 시 적절한 롤백 로직을 구현해야 합니다.
다음과 같이 에러 핸들링을 추가하는 것을 권장합니다:
await _tokenRepository.saveToken(token.accessToken);
if (token.refreshToken != null) {
await _tokenRepository.saveRefreshToken(token.refreshToken!);
}
- await _api.login(token.accessToken);
+ try {
+ await _api.login(token.accessToken);
+ } catch (e) {
+ // API 호출 실패 시 로깅하지만 로그인은 계속 진행
+ // 또는 필요에 따라 토큰을 롤백할 수 있음
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| await _api.login(token.accessToken); | |
| await _tokenRepository.saveToken(token.accessToken); | |
| if (token.refreshToken != null) { | |
| await _tokenRepository.saveRefreshToken(token.refreshToken!); | |
| } | |
| - await _api.login(token.accessToken); | |
| + try { | |
| + await _api.login(token.accessToken); | |
| + } catch (e) { | |
| + // API 호출 실패 시 로깅하지만 로그인은 계속 진행 | |
| + // 또는 필요에 따라 토큰을 롤백할 수 있음 | |
| + } |
🤖 Prompt for AI Agents
In lib/app/modules/user/data/repositories/rest_auth_repository.dart around line
31, the new await _api.login(token.accessToken) call lacks error handling; wrap
this call in a try/catch so the repository handles failures: either swallow the
error (log it) and return success so the saved token keeps the user logged in,
or perform a rollback by deleting the stored token and rethrowing or returning a
failure result; ensure you log the error and choose a clear contract
(bool/result) so callers know whether login finalization succeeded.
Summary by CodeRabbit