Skip to content

Commit 394aa40

Browse files
authored
Merge pull request #51 from Nexters/qa/1.0.0
1.0.0 QA 브랜치 dev브랜치에 머지합니다.
2 parents 121870d + e231e5b commit 394aa40

File tree

24 files changed

+231
-74
lines changed

24 files changed

+231
-74
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
android:name="com.plottwist.feature.main.MainActivity"
1919
android:exported="true"
2020
android:label="@string/app_name"
21+
android:launchMode="singleTop"
2122
android:theme="@style/Theme.Tuk"
2223
android:screenOrientation="portrait"
2324
android:windowSoftInputMode="adjustResize">

build-logic/convention/src/main/kotlin/com/plottwist/tuk/Extension.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fun ApplicationExtension.configureDefaultConfig() {
1111
defaultConfig {
1212
applicationId = "com.plottwist.tuk"
1313
targetSdk = 36
14-
versionCode = 4
14+
versionCode = 5
1515
versionName = "1.0.0"
1616

1717
vectorDrawables {

core/data/src/main/java/com/plottwist/core/data/auth/repository/AuthRepositoryImpl.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.plottwist.core.domain.onboarding.OnboardingRepository
66
import com.plottwist.core.domain.push.repository.PushRepository
77
import com.plottwist.core.network.model.auth.DeviceInfo
88
import com.plottwist.core.network.model.auth.GoogleLoginRequest
9+
import com.plottwist.core.network.model.auth.TokenRequest
910
import com.plottwist.core.network.model.onboarding.MemberNameRequest
1011
import com.plottwist.core.network.service.AuthApiService
1112
import com.plottwist.core.network.service.TukApiService
@@ -14,7 +15,6 @@ import kotlinx.coroutines.flow.Flow
1415
import kotlinx.coroutines.flow.collect
1516
import kotlinx.coroutines.flow.combine
1617
import kotlinx.coroutines.flow.firstOrNull
17-
import kotlinx.coroutines.flow.onEach
1818
import javax.inject.Inject
1919

2020

@@ -126,4 +126,25 @@ class AuthRepositoryImpl @Inject constructor(
126126
override fun setMemberName(name: String): Flow<Unit> {
127127
return authDataSource.setMemberName(name)
128128
}
129+
130+
override suspend fun reissueTokens(): Result<Unit> {
131+
try {
132+
val refreshToken = authDataSource.getRefreshToken().firstOrNull()
133+
if(refreshToken.isNullOrEmpty()){
134+
authDataSource.clear()
135+
return Result.failure(Exception("Fail Reissue Tokens"))
136+
}
137+
val result = authApiService.refreshToken(TokenRequest(refreshToken))
138+
139+
return if (result.success) {
140+
authDataSource.setAccessToken(result.data.accessToken).collect()
141+
authDataSource.setRefreshToken(result.data.refreshToken).collect()
142+
Result.success(Unit)
143+
} else {
144+
Result.failure(Exception("Fail Delete member"))
145+
}
146+
} catch (e: Exception) {
147+
return Result.failure(e)
148+
}
149+
}
129150
}

core/designsystem/src/main/java/com/plottwist/core/designsystem/component/TextField.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fun TukTextField(
110110
innerTextField()
111111
}
112112
}
113-
if (state.text.isNotEmpty()) {
113+
if (state.text.isNotEmpty() && isFocus) {
114114
ClearButton(
115115
modifier = Modifier.padding(end = 10.dp),
116116
onClick = onClear
384 KB
Loading

core/designsystem/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
<string name="create_proposal_title">이렇게 전해질 거예요,\n한번 볼까요?</string>
2828
<string name="create_proposal_select_gathering">모임 선택</string>
29-
<string name="create_proposal_propose">툭, 찔러보기</string>
29+
<string name="create_proposal_propose">다음</string>
3030
<string name="create_proposal_selected_gathering_name">%s 친구들에게</string>
3131

3232
<string name="onboarding_name_title">어떤 이름으로 친구들에게\n인사할까요?</string>

core/domain/src/main/java/com/plottwist/core/domain/auth/repository/AuthRepository.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ interface AuthRepository {
1111
suspend fun updateMemberName(name: String): Result<Unit>
1212
fun getMemberName(): Flow<String?>
1313
fun setMemberName(name: String): Flow<Unit>
14+
suspend fun reissueTokens(): Result<Unit>
1415
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.plottwist.core.domain.auth.usecase
2+
3+
import com.plottwist.core.domain.auth.repository.AuthRepository
4+
import javax.inject.Inject
5+
6+
class ReissueTokensUseCase @Inject constructor(
7+
private val loginRepository: AuthRepository
8+
) {
9+
suspend operator fun invoke(): Result<Unit> {
10+
return loginRepository.reissueTokens()
11+
}
12+
}

core/network/src/main/java/com/plottwist/core/network/interceptor/TokenInterceptor.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.plottwist.core.network.interceptor
22

33
import com.plottwist.core.network.TokenProvider
4+
import com.plottwist.core.network.model.auth.TokenRequest
5+
import com.plottwist.core.network.service.AuthApiService
46
import kotlinx.coroutines.CoroutineScope
57
import kotlinx.coroutines.Dispatchers
68
import kotlinx.coroutines.launch
@@ -13,6 +15,7 @@ import javax.inject.Singleton
1315

1416
@Singleton
1517
class TokenInterceptor @Inject constructor(
18+
private val authApiService: AuthApiService,
1619
private val tokenProvider: TokenProvider
1720
) : Interceptor {
1821

@@ -38,6 +41,26 @@ class TokenInterceptor @Inject constructor(
3841
}
3942
}
4043
}
44+
HttpURLConnection.HTTP_UNAUTHORIZED -> {
45+
val retryRequest = chain.request().newBuilder().apply {
46+
runBlocking {
47+
tokenProvider.getRefreshToken()?.let {
48+
val newToken = authApiService.refreshToken(TokenRequest(it))
49+
if (newToken.success) {
50+
newToken.data.let { token ->
51+
addHeader("Authorization", "Bearer ${token.accessToken}")
52+
CoroutineScope(Dispatchers.IO).launch {
53+
tokenProvider.setAccessToken(token.accessToken)
54+
tokenProvider.setRefreshToken(token.refreshToken)
55+
}
56+
}
57+
}
58+
}
59+
}
60+
}
61+
response.close()
62+
return chain.proceed(retryRequest.build())
63+
}
4164
}
4265
return response
4366
}

core/network/src/main/java/com/plottwist/core/network/model/auth/GoogleLoginRequest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ data class DeviceInfo(
2121
data class DeviceInfoRequest(
2222
val deviceInfo : DeviceInfo
2323
)
24+
25+
@Serializable
26+
data class TokenRequest(
27+
val refreshToken: String,
28+
)

0 commit comments

Comments
 (0)