-
Notifications
You must be signed in to change notification settings - Fork 0
[Refactor/#83] 자동 로그인 로직 변경 #85
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 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
df92e6f
Feat: userRole 타입 추가
wjdrjs00 1bbd5ee
Refactor: 자동 로그인 기능 변경
wjdrjs00 75ccd7b
Feat: 토큰 재발급 api 연동
wjdrjs00 aabecdf
Refactor: 스플래시 MVI 모델 수정
wjdrjs00 6911cc9
Refactor: 스플래시 화면 자동 로그인 분기 처리
wjdrjs00 0e00baa
Feat: 재발급 중복 호출 방지를 위한 헤더 추가
wjdrjs00 a868f00
Refactor: 예외 핸들링 로직 수정
wjdrjs00 d22e0e4
Refactor: 자동로그인 실패 시 예외처리
wjdrjs00 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
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
4 changes: 1 addition & 3 deletions
4
data/src/main/java/com/threegap/bitnagil/data/auth/datasource/AuthLocalDataSource.kt
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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
package com.threegap.bitnagil.data.auth.datasource | ||
|
||
interface AuthLocalDataSource { | ||
suspend fun hasToken(): Boolean | ||
|
||
suspend fun getRefreshToken(): String? | ||
suspend fun updateAuthToken(accessToken: String, refreshToken: String): Result<Unit> | ||
|
||
suspend fun clearAuthToken(): Result<Unit> | ||
} |
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
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
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
29 changes: 29 additions & 0 deletions
29
domain/src/main/java/com/threegap/bitnagil/domain/auth/usecase/AutoLoginUseCase.kt
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.threegap.bitnagil.domain.auth.usecase | ||
|
||
import com.threegap.bitnagil.domain.auth.model.UserRole | ||
import com.threegap.bitnagil.domain.auth.repository.AuthRepository | ||
import javax.inject.Inject | ||
|
||
class AutoLoginUseCase @Inject constructor( | ||
private val authRepository: AuthRepository, | ||
) { | ||
suspend operator fun invoke(): UserRole { | ||
val refreshToken = authRepository.getRefreshToken() | ||
if (refreshToken.isNullOrEmpty()) return UserRole.UNKNOWN | ||
|
||
return authRepository.reissueToken(refreshToken) | ||
.onSuccess { authSession -> | ||
authRepository.updateAuthToken( | ||
accessToken = authSession.accessToken, | ||
refreshToken = authSession.refreshToken, | ||
) | ||
} | ||
.onFailure { | ||
authRepository.clearAuthToken() | ||
} | ||
.fold( | ||
onSuccess = { authSession -> authSession.role }, | ||
onFailure = { UserRole.UNKNOWN }, | ||
) | ||
l5x5l marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
domain/src/main/java/com/threegap/bitnagil/domain/auth/usecase/HasTokenUseCase.kt
This file was deleted.
Oops, something went wrong.
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
wjdrjs00 marked this conversation as resolved.
Show resolved
Hide resolved
|
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
5 changes: 4 additions & 1 deletion
5
presentation/src/main/java/com/threegap/bitnagil/presentation/splash/model/SplashIntent.kt
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package com.threegap.bitnagil.presentation.splash.model | ||
|
||
import com.threegap.bitnagil.domain.auth.model.UserRole | ||
import com.threegap.bitnagil.presentation.common.mviviewmodel.MviIntent | ||
|
||
sealed class SplashIntent : MviIntent { | ||
data class SetTokenChecked(val hasToken: Boolean?) : SplashIntent() | ||
data class SetUserRole(val userRole: UserRole?) : SplashIntent() | ||
data object NavigateToIntro : SplashIntent() | ||
data object NavigateToHome : SplashIntent() | ||
data object NavigateToTermsAgreement : SplashIntent() | ||
data object NavigateToOnboarding : SplashIntent() | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.