Skip to content

Commit ab4bde7

Browse files
authored
Merge pull request #88 from YAPP-Github/release/1.0.2
[Release/1.0.2] (main)
2 parents b33169a + d8aae68 commit ab4bde7

File tree

59 files changed

+482
-346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+482
-346
lines changed

app/src/main/java/com/threegap/bitnagil/MainNavHost.kt

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ fun MainNavHost(
3838
popUpTo<Route.Splash> { inclusive = true }
3939
}
4040
},
41-
navigateToHome = {
42-
navigator.navController.navigate(Route.Home) {
43-
popUpTo(navigator.navController.graph.startDestinationId) {
44-
inclusive = true
45-
}
41+
navigateToTermsAgreement = {
42+
navigator.navController.navigate(Route.TermsAgreement) {
43+
popUpTo<Route.Splash> { inclusive = true }
4644
}
4745
},
46+
navigateToOnboarding = {
47+
navigator.navController.navigate(Route.OnBoarding()) {
48+
popUpTo<Route.Splash> { inclusive = true }
49+
}
50+
},
51+
navigateToHome = navigator::navigateToHomeAndClearStack,
4852
)
4953
}
5054

@@ -56,13 +60,7 @@ fun MainNavHost(
5660

5761
composable<Route.Login> {
5862
LoginScreenContainer(
59-
navigateToHome = {
60-
navigator.navController.navigate(Route.Home) {
61-
popUpTo(navigator.navController.graph.startDestinationId) {
62-
inclusive = true
63-
}
64-
}
65-
},
63+
navigateToHome = navigator::navigateToHomeAndClearStack,
6664
navigateToTermsAgreement = { navigator.navController.navigate(Route.TermsAgreement) },
6765
)
6866
}
@@ -192,13 +190,7 @@ fun MainNavHost(
192190

193191
OnBoardingScreenContainer(
194192
onBoardingViewModel = viewModel,
195-
navigateToHome = {
196-
navigator.navController.navigate(Route.Home) {
197-
popUpTo(navigator.navController.graph.startDestinationId) {
198-
inclusive = true
199-
}
200-
}
201-
},
193+
navigateToHome = navigator::navigateToHomeAndClearStack,
202194
navigateToBack = {
203195
if (navigator.navController.previousBackStackEntry != null) {
204196
navigator.navController.popBackStack()

app/src/main/java/com/threegap/bitnagil/MainNavigator.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ class MainNavigator(
99
val navController: NavHostController,
1010
) {
1111
val startDestination = Route.Splash
12+
13+
internal fun navigateToHomeAndClearStack() =
14+
navController.navigate(Route.Home) {
15+
popUpTo(0) {
16+
inclusive = true
17+
}
18+
}
1219
}
1320

1421
@Composable

app/src/main/java/com/threegap/bitnagil/navigation/home/HomeNavHost.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.app.Activity
55
import androidx.activity.compose.BackHandler
66
import androidx.compose.foundation.background
77
import androidx.compose.foundation.layout.Box
8+
import androidx.compose.foundation.layout.WindowInsets
89
import androidx.compose.foundation.layout.fillMaxSize
910
import androidx.compose.foundation.layout.padding
1011
import androidx.compose.material3.Scaffold
@@ -53,11 +54,12 @@ fun HomeNavHost(
5354
bottomBar = {
5455
HomeBottomNavigationBar(navController = navigator.navController)
5556
},
56-
content = { _ ->
57+
contentWindowInsets = WindowInsets(0.dp, 0.dp, 0.dp, 0.dp),
58+
content = { innerPadding ->
5759
NavHost(
5860
navController = navigator.navController,
5961
startDestination = navigator.startDestination,
60-
modifier = modifier,
62+
modifier = modifier.padding(innerPadding),
6163
) {
6264
composable(HomeRoute.Home.route) {
6365
HomeScreenContainer(

core/datastore/src/main/java/com/threegap/bitnagil/datastore/auth/storage/AuthTokenDataStore.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@ import kotlinx.coroutines.flow.Flow
55

66
interface AuthTokenDataStore {
77
val tokenFlow: Flow<AuthToken>
8-
9-
suspend fun hasToken(): Boolean
10-
118
suspend fun updateAuthToken(accessToken: String, refreshToken: String)
12-
139
suspend fun updateAccessToken(accessToken: String)
14-
1510
suspend fun updateRefreshToken(refreshToken: String)
16-
1711
suspend fun clearAuthToken()
1812
}

core/datastore/src/main/java/com/threegap/bitnagil/datastore/auth/storage/AuthTokenDataStoreImpl.kt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,12 @@ package com.threegap.bitnagil.datastore.auth.storage
33
import androidx.datastore.core.DataStore
44
import com.threegap.bitnagil.datastore.auth.model.AuthToken
55
import kotlinx.coroutines.flow.Flow
6-
import kotlinx.coroutines.flow.firstOrNull
76

87
class AuthTokenDataStoreImpl(
98
private val dataStore: DataStore<AuthToken>,
109
) : AuthTokenDataStore {
1110
override val tokenFlow: Flow<AuthToken> = dataStore.data
1211

13-
override suspend fun hasToken(): Boolean {
14-
return try {
15-
val currentToken = dataStore.data.firstOrNull()
16-
currentToken?.let {
17-
!it.accessToken.isNullOrEmpty() && !it.refreshToken.isNullOrEmpty()
18-
} ?: false
19-
} catch (e: Exception) {
20-
false
21-
}
22-
}
23-
2412
override suspend fun updateAuthToken(accessToken: String, refreshToken: String) {
2513
try {
2614
dataStore.updateData {
@@ -58,8 +46,4 @@ class AuthTokenDataStoreImpl(
5846
throw e
5947
}
6048
}
61-
62-
companion object {
63-
private const val TAG = "AuthTokenDataStore"
64-
}
6549
}

core/network/src/main/java/com/threegap/bitnagil/network/auth/TokenAuthenticator.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class TokenAuthenticator(
1919
private val authMutex = Mutex()
2020

2121
override fun authenticate(route: Route?, response: Response): Request? {
22+
if (response.request.header(AUTO_LOGIN_HEADER) != null) return null
2223
if (!shouldRetry(response)) return null
2324

2425
val currentToken = runBlocking { tokenProvider.getAccessToken() }
@@ -82,6 +83,7 @@ class TokenAuthenticator(
8283
private fun buildRequestWithToken(originalRequest: Request, token: String): Request {
8384
return originalRequest.newBuilder()
8485
.header(AUTHORIZATION, "$TOKEN_PREFIX $token")
86+
.removeHeader(AUTO_LOGIN_HEADER)
8587
.build()
8688
}
8789

@@ -96,5 +98,6 @@ class TokenAuthenticator(
9698
private const val AUTHORIZATION = "Authorization"
9799
private const val TOKEN_PREFIX = "Bearer"
98100
private const val SUCCESS_CODE = "CO000"
101+
private const val AUTO_LOGIN_HEADER = "Auto-Login"
99102
}
100103
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.threegap.bitnagil.data.auth.datasource
22

33
interface AuthLocalDataSource {
4-
suspend fun hasToken(): Boolean
5-
4+
suspend fun getRefreshToken(): String?
65
suspend fun updateAuthToken(accessToken: String, refreshToken: String): Result<Unit>
7-
86
suspend fun clearAuthToken(): Result<Unit>
97
}

data/src/main/java/com/threegap/bitnagil/data/auth/datasource/AuthRemoteDataSource.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import com.threegap.bitnagil.data.auth.model.response.LoginResponseDto
66

77
interface AuthRemoteDataSource {
88
suspend fun login(socialAccessToken: String, loginRequestDto: LoginRequestDto): Result<LoginResponseDto>
9-
109
suspend fun submitAgreement(termsAgreementRequestDto: TermsAgreementRequestDto): Result<Unit>
11-
1210
suspend fun logout(): Result<Unit>
13-
1411
suspend fun withdrawal(): Result<Unit>
12+
suspend fun reissueToken(refreshToken: String): Result<LoginResponseDto>
1513
}

data/src/main/java/com/threegap/bitnagil/data/auth/datasourceimpl/AuthLocalDataSourceImpl.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ package com.threegap.bitnagil.data.auth.datasourceimpl
22

33
import com.threegap.bitnagil.data.auth.datasource.AuthLocalDataSource
44
import com.threegap.bitnagil.datastore.auth.storage.AuthTokenDataStore
5+
import kotlinx.coroutines.flow.firstOrNull
56
import javax.inject.Inject
67

78
class AuthLocalDataSourceImpl @Inject constructor(
89
private val authTokenDataStore: AuthTokenDataStore,
910
) : AuthLocalDataSource {
1011

11-
override suspend fun hasToken(): Boolean = authTokenDataStore.hasToken()
12+
override suspend fun getRefreshToken(): String? =
13+
runCatching {
14+
authTokenDataStore.tokenFlow.firstOrNull()?.refreshToken
15+
}.getOrNull()
1216

1317
override suspend fun updateAuthToken(accessToken: String, refreshToken: String): Result<Unit> =
1418
runCatching {

data/src/main/java/com/threegap/bitnagil/data/auth/datasourceimpl/AuthRemoteDataSourceImpl.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ class AuthRemoteDataSourceImpl @Inject constructor(
3131
safeUnitApiCall {
3232
authService.postWithdrawal()
3333
}
34+
35+
override suspend fun reissueToken(refreshToken: String): Result<LoginResponseDto> =
36+
safeApiCall {
37+
authService.postReissueToken(refreshToken)
38+
}
3439
}

0 commit comments

Comments
 (0)