-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/360
- Loading branch information
Showing
100 changed files
with
2,030 additions
and
1,437 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
data/src/main/java/com/nexters/boolti/data/datasource/AuthTokenDataSource.kt
This file contains 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,23 @@ | ||
package com.nexters.boolti.data.datasource | ||
|
||
import javax.inject.Inject | ||
|
||
internal class AuthTokenDataSource @Inject constructor( | ||
private val authDataSource: AuthDataSource, | ||
private val tokenDataSource: TokenDataSource, | ||
) { | ||
suspend fun getNewAccessToken(): String? { | ||
val response = authDataSource.refresh() | ||
val newToken = response.getOrNull() | ||
return newToken?.let { | ||
tokenDataSource.saveTokens( | ||
accessToken = it.accessToken, | ||
refreshToken = it.refreshToken, | ||
) | ||
it.accessToken | ||
} ?: run { | ||
authDataSource.logout() | ||
null | ||
} | ||
} | ||
} |
This file contains 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 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 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 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 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
8 changes: 7 additions & 1 deletion
8
.../nexters/boolti/domain/model/TokenPair.kt → ...nexters/boolti/domain/model/TokenPairs.kt
This file contains 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,8 +1,14 @@ | ||
package com.nexters.boolti.domain.model | ||
|
||
data class TokenPair( | ||
data class TokenPairs( | ||
val accessToken: String, | ||
val refreshToken: String, | ||
) { | ||
val isLoggedIn: Boolean = accessToken.isNotBlank() && refreshToken.isNotBlank() | ||
} | ||
|
||
@JvmInline | ||
value class AccessToken(val token: String) | ||
|
||
@JvmInline | ||
value class RefreshToken(val token: String) |
This file contains 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 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 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 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.