-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix] 로그인 / 로그아웃 토큰 및 네비게이션 수정 #14 #21
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
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import com.konkuk.medicarecall.data.api.auth.AuthService | |
| import com.konkuk.medicarecall.data.api.member.SettingService | ||
| import com.konkuk.medicarecall.data.mapper.UserMapper | ||
| import com.konkuk.medicarecall.data.repository.DataStoreRepository | ||
| import com.konkuk.medicarecall.data.repository.ElderIdRepository | ||
| import com.konkuk.medicarecall.data.repository.UserRepository | ||
| import com.konkuk.medicarecall.data.util.handleNullableResponse | ||
| import com.konkuk.medicarecall.data.util.handleResponse | ||
|
|
@@ -15,6 +16,7 @@ class UserRepositoryImpl( | |
| private val settingService: SettingService, | ||
| private val authService: AuthService, | ||
| private val tokenStore: DataStoreRepository, | ||
| private val elderIdRepository: ElderIdRepository, | ||
| ) : UserRepository { | ||
| override suspend fun getMyInfo() = runCatching { | ||
| val responseDto = settingService.getMyInfo().handleResponse() | ||
|
|
@@ -27,10 +29,18 @@ class UserRepositoryImpl( | |
| UserMapper.toDomain(responseDto) | ||
| } | ||
|
|
||
| override suspend fun logout(): Result<Unit> = runCatching { | ||
| val refresh = tokenStore.getRefreshToken() ?: error("Refresh token is null") | ||
| authService.logout("Bearer $refresh").handleNullableResponse() | ||
| // 성공/실패와 무관하게 로컬 토큰 제거(보안/UX 측면에서 권장) | ||
| override suspend fun logout(): Result<Unit> { | ||
| runCatching { | ||
| val refresh = tokenStore.getRefreshToken() | ||
| if (!refresh.isNullOrBlank()) { | ||
| authService.logout("Bearer $refresh").handleNullableResponse() | ||
| } | ||
| } | ||
|
|
||
| tokenStore.clearTokens() | ||
| elderIdRepository.clearElderIds() | ||
|
|
||
| return Result.success(Unit) | ||
|
Comment on lines
+33
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 로컬 cleanup도 지금은 서버 로그아웃만 🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refresh 실패 시 토큰을 부분적으로만 지우면 상태가 꼬입니다.
여기서는 빈 refresh token, 예외, 실패 응답을 전부
saveRefreshToken("")로 처리하고 있어서 access token은 그대로 남습니다. 그러면 토큰 저장소가 반쯤만 비워진 상태가 되고, 일시적인 네트워크/서버 장애까지 세션 만료로 오인하게 돼요. 재발급이 확실히 불가능한 경우에만clearTokens()로 둘을 함께 정리하고, 그 외 실패는 저장값을 유지한 채null만 반환하는 쪽이 더 안전합니다.Also applies to: 104-107
🤖 Prompt for AI Agents