Skip to content

Commit 0152df0

Browse files
committed
[FEATURE]#205 : 로그인 바디, 토큰 모델이 아닌 SignIn으로 변경
1 parent d054f17 commit 0152df0

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.bff.wespot.data.remote.source.auth
22

3-
import com.bff.wespot.data.remote.model.auth.request.KakaoAuthTokenDto
3+
import com.bff.wespot.data.remote.model.auth.request.SignInDto
44
import com.bff.wespot.data.remote.model.auth.request.SignUpDto
55
import com.bff.wespot.data.remote.model.auth.response.AuthTokenDto
66
import com.bff.wespot.data.remote.model.auth.response.SchoolListDto
77
import com.bff.wespot.model.auth.request.RevokeReasonListDto
88

99
interface AuthDataSource {
1010
suspend fun getSchoolList(search: String, cursorId: Int?): Result<SchoolListDto>
11-
suspend fun sendKakaoToken(token: KakaoAuthTokenDto): Result<Any>
11+
suspend fun signIn(signIn: SignInDto): Result<Any>
1212
suspend fun signUp(signUp: SignUpDto): Result<AuthTokenDto>
1313
suspend fun revoke(revokeReasonList: RevokeReasonListDto): Result<Unit>
1414
}

data-remote/src/main/kotlin/com/bff/wespot/data/remote/source/auth/AuthDataSourceImpl.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.bff.wespot.data.remote.source.auth
22

33
import com.bff.wespot.data.remote.extensions.invalidateBearerTokens
4-
import com.bff.wespot.data.remote.model.auth.request.KakaoAuthTokenDto
4+
import com.bff.wespot.data.remote.model.auth.request.SignInDto
55
import com.bff.wespot.data.remote.model.auth.request.SignUpDto
66
import com.bff.wespot.data.remote.model.auth.response.AuthTokenDto
77
import com.bff.wespot.data.remote.model.auth.response.SchoolListDto
@@ -27,13 +27,13 @@ class AuthDataSourceImpl @Inject constructor(
2727
}
2828
}
2929

30-
override suspend fun sendKakaoToken(token: KakaoAuthTokenDto): Result<Any> {
30+
override suspend fun signIn(signIn: SignInDto): Result<Any> {
3131
val client = httpClient.safeRequest<Any> {
3232
url {
3333
method = HttpMethod.Post
3434
path("api/v1/auth/login")
3535
}
36-
setBody(token)
36+
setBody(signIn)
3737
}
3838
httpClient.invalidateBearerTokens()
3939
return client

data/src/main/kotlin/com/bff/wespot/data/repository/auth/AuthRepositoryImpl.kt

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import com.bff.wespot.data.remote.model.auth.response.SignUpTokenDto
77
import com.bff.wespot.data.remote.source.auth.AuthDataSource
88
import com.bff.wespot.domain.repository.auth.AuthRepository
99
import com.bff.wespot.domain.util.DataStoreKey
10-
import com.bff.wespot.model.auth.request.KakaoAuthToken
1110
import com.bff.wespot.model.auth.request.RevokeReasonListDto
11+
import com.bff.wespot.model.auth.request.SignIn
1212
import com.bff.wespot.model.auth.request.SignUp
1313
import kotlinx.coroutines.flow.first
1414
import javax.inject.Inject
@@ -17,9 +17,11 @@ class AuthRepositoryImpl @Inject constructor(
1717
private val authDataSource: AuthDataSource,
1818
private val dataStore: WeSpotDataStore
1919
) : AuthRepository {
20-
override suspend fun sendKakaoToken(token: KakaoAuthToken): Result<Any> =
21-
authDataSource
22-
.sendKakaoToken(token.toDto(dataStore.getString(DataStoreKey.PUSH_TOKEN).first()))
20+
override suspend fun signIn(signIn: SignIn): Result<Any> {
21+
val fcmToken = dataStore.getString(DataStoreKey.PUSH_TOKEN).first()
22+
val signInDto = signIn.toDto(fcmToken)
23+
return authDataSource
24+
.signIn(signInDto)
2325
.mapCatching {
2426
when (it) {
2527
is AuthTokenDto -> {
@@ -33,6 +35,7 @@ class AuthRepositoryImpl @Inject constructor(
3335
else -> throw IllegalArgumentException("Unknown token type")
3436
}
3537
}
38+
}
3639

3740
override suspend fun signUp(signUp: SignUp): Boolean {
3841
val response = authDataSource
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.bff.wespot.domain.repository.auth
22

3-
import com.bff.wespot.model.auth.request.KakaoAuthToken
3+
import com.bff.wespot.model.auth.request.SignIn
44
import com.bff.wespot.model.auth.request.SignUp
55

66
interface AuthRepository {
7-
suspend fun sendKakaoToken(token: KakaoAuthToken): Result<Any>
7+
suspend fun signIn(signIn: SignIn): Result<Any>
88
suspend fun signUp(signUp: SignUp): Boolean
99
suspend fun revoke(revokeReasonList: List<String>): Result<Unit>
1010
}

domain/src/main/kotlin/com/bff/wespot/domain/usecase/KakaoLoginUseCase.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.bff.wespot.domain.repository.DataStoreRepository
44
import com.bff.wespot.domain.repository.auth.AuthRepository
55
import com.bff.wespot.domain.repository.firebase.messaging.MessagingRepository
66
import com.bff.wespot.domain.util.DataStoreKey
7-
import com.bff.wespot.model.auth.request.KakaoAuthToken
7+
import com.bff.wespot.model.auth.request.SignIn
88
import com.bff.wespot.model.auth.response.AuthToken
99
import com.bff.wespot.model.auth.response.SignUpToken
1010
import com.bff.wespot.model.constants.LoginState
@@ -15,11 +15,11 @@ class KakaoLoginUseCase @Inject constructor(
1515
private val authRepository: AuthRepository,
1616
private val dataStoreRepository: DataStoreRepository,
1717
) {
18-
suspend operator fun invoke(result: KakaoAuthToken): Result<LoginState> {
18+
suspend operator fun invoke(signIn: SignIn): Result<LoginState> {
1919
val token = messagingRepository.getFcmToken()
2020
dataStoreRepository.saveString(DataStoreKey.PUSH_TOKEN, token)
2121

22-
return authRepository.sendKakaoToken(result)
22+
return authRepository.signIn(signIn)
2323
.map {
2424
when (it) {
2525
is AuthToken -> {

0 commit comments

Comments
 (0)