From 922b1bb5f2b84bc1789efadee41fa5f593272b31 Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Thu, 19 Dec 2024 22:23:19 +0900 Subject: [PATCH 01/12] =?UTF-8?q?chore:=20kakao=20login=20repository=20?= =?UTF-8?q?=ED=8C=A8=ED=82=A4=EC=A7=80=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thirdparty/login/kakao => auth}/KakaoLoginRepository.kt | 3 ++- .../app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) rename android/app/src/main/java/com/mulberry/ody/data/{remote/thirdparty/login/kakao => auth}/KakaoLoginRepository.kt (97%) diff --git a/android/app/src/main/java/com/mulberry/ody/data/remote/thirdparty/login/kakao/KakaoLoginRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoLoginRepository.kt similarity index 97% rename from android/app/src/main/java/com/mulberry/ody/data/remote/thirdparty/login/kakao/KakaoLoginRepository.kt rename to android/app/src/main/java/com/mulberry/ody/data/auth/KakaoLoginRepository.kt index 8550e8e82..97cb9c72e 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/remote/thirdparty/login/kakao/KakaoLoginRepository.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoLoginRepository.kt @@ -1,4 +1,4 @@ -package com.mulberry.ody.data.remote.thirdparty.login.kakao +package com.mulberry.ody.data.auth import android.content.Context import com.mulberry.ody.data.remote.core.entity.login.mapper.toAuthToken @@ -8,6 +8,7 @@ import com.mulberry.ody.data.remote.core.service.LogoutService import com.mulberry.ody.data.remote.core.service.MemberService import com.mulberry.ody.data.remote.core.service.RefreshTokenService import com.mulberry.ody.data.remote.thirdparty.login.entity.UserProfile +import com.mulberry.ody.data.remote.thirdparty.login.kakao.KakaoOAuthLoginService import com.mulberry.ody.domain.apiresult.ApiResult import com.mulberry.ody.domain.apiresult.map import com.mulberry.ody.domain.apiresult.suspendOnSuccess diff --git a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt index 6bbdc5e0a..0be75cd9e 100644 --- a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt +++ b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt @@ -7,7 +7,7 @@ import com.mulberry.ody.data.remote.core.repository.DefaultJoinRepository import com.mulberry.ody.data.remote.core.repository.DefaultMeetingRepository import com.mulberry.ody.data.remote.core.repository.DefaultNotificationLogRepository import com.mulberry.ody.data.remote.thirdparty.address.KakaoAddressRepository -import com.mulberry.ody.data.remote.thirdparty.login.kakao.KakaoLoginRepository +import com.mulberry.ody.data.auth.KakaoLoginRepository import com.mulberry.ody.domain.repository.location.AddressRepository import com.mulberry.ody.domain.repository.ody.AuthTokenRepository import com.mulberry.ody.domain.repository.ody.FCMTokenRepository From cad27a61184990ededa251c157ac402dd2b6a5e8 Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Thu, 19 Dec 2024 22:31:03 +0900 Subject: [PATCH 02/12] =?UTF-8?q?refactor:=20token=20repository=EB=A5=BC?= =?UTF-8?q?=20local=20data=20source=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/source/DefaultLocalAuthDataSource.kt | 30 +++++++++++++++++++ .../data/auth/source/LocalAuthDataSource.kt | 15 ++++++++++ .../repository/DefaultAuthTokenRepository.kt | 25 ---------------- .../repository/DefaultFCMTokenRepository.kt | 18 ----------- .../repository/ody/AuthTokenRepository.kt | 11 ------- .../repository/ody/FCMTokenRepository.kt | 7 ----- 6 files changed, 45 insertions(+), 61 deletions(-) create mode 100644 android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultLocalAuthDataSource.kt create mode 100644 android/app/src/main/java/com/mulberry/ody/data/auth/source/LocalAuthDataSource.kt delete mode 100644 android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt delete mode 100644 android/app/src/main/java/com/mulberry/ody/data/remote/core/repository/DefaultFCMTokenRepository.kt delete mode 100644 android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt delete mode 100644 android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultLocalAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultLocalAuthDataSource.kt new file mode 100644 index 000000000..59cfad870 --- /dev/null +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultLocalAuthDataSource.kt @@ -0,0 +1,30 @@ +package com.mulberry.ody.data.auth.source + +import com.mulberry.ody.data.local.db.OdyDatastore +import com.mulberry.ody.domain.model.AuthToken +import kotlinx.coroutines.flow.first +import javax.inject.Inject + +class DefaultLocalAuthDataSource +@Inject +constructor( + private val odyDatastore: OdyDatastore, +) : LocalAuthDataSource { + override suspend fun fetchAuthToken(): Result { + return odyDatastore.getAuthToken().first() + } + + override suspend fun removeAuthToken() { + odyDatastore.removeAuthToken() + } + + override suspend fun postAuthToken(authToken: AuthToken) { + odyDatastore.setAuthToken(authToken) + } + + override suspend fun fetchFCMToken(): Result { + return odyDatastore.getFCMToken().first() + } + + override suspend fun postFCMToken(fcmToken: String) = odyDatastore.setFCMToken(fcmToken) +} diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/LocalAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/LocalAuthDataSource.kt new file mode 100644 index 000000000..f0761f32d --- /dev/null +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/LocalAuthDataSource.kt @@ -0,0 +1,15 @@ +package com.mulberry.ody.data.auth.source + +import com.mulberry.ody.domain.model.AuthToken + +interface LocalAuthDataSource { + suspend fun fetchAuthToken(): Result + + suspend fun removeAuthToken() + + suspend fun postAuthToken(authToken: AuthToken) + + suspend fun fetchFCMToken(): Result + + suspend fun postFCMToken(fcmToken: String) +} diff --git a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt deleted file mode 100644 index 6ecec1cdc..000000000 --- a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.mulberry.ody.data.local.repository - -import com.mulberry.ody.data.local.db.OdyDatastore -import com.mulberry.ody.domain.model.AuthToken -import com.mulberry.ody.domain.repository.ody.AuthTokenRepository -import kotlinx.coroutines.flow.first -import javax.inject.Inject - -class DefaultAuthTokenRepository - @Inject - constructor( - private val odyDatastore: OdyDatastore, - ) : AuthTokenRepository { - override suspend fun fetchAuthToken(): Result { - return odyDatastore.getAuthToken().first() - } - - override suspend fun removeAuthToken() { - odyDatastore.removeAuthToken() - } - - override suspend fun setAuthToken(authToken: AuthToken) { - odyDatastore.setAuthToken(authToken) - } - } diff --git a/android/app/src/main/java/com/mulberry/ody/data/remote/core/repository/DefaultFCMTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/remote/core/repository/DefaultFCMTokenRepository.kt deleted file mode 100644 index 479c6a4a0..000000000 --- a/android/app/src/main/java/com/mulberry/ody/data/remote/core/repository/DefaultFCMTokenRepository.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.mulberry.ody.data.remote.core.repository - -import com.mulberry.ody.data.local.db.OdyDatastore -import com.mulberry.ody.domain.repository.ody.FCMTokenRepository -import kotlinx.coroutines.flow.first -import javax.inject.Inject - -class DefaultFCMTokenRepository - @Inject - constructor( - private val odyDatastore: OdyDatastore, - ) : FCMTokenRepository { - override suspend fun fetchFCMToken(): Result { - return odyDatastore.getFCMToken().first() - } - - override suspend fun postFCMToken(fcmToken: String) = odyDatastore.setFCMToken(fcmToken) - } diff --git a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt deleted file mode 100644 index cac5935f9..000000000 --- a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.mulberry.ody.domain.repository.ody - -import com.mulberry.ody.domain.model.AuthToken - -interface AuthTokenRepository { - suspend fun fetchAuthToken(): Result - - suspend fun removeAuthToken() - - suspend fun setAuthToken(authToken: AuthToken) -} diff --git a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt deleted file mode 100644 index df3004a02..000000000 --- a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.mulberry.ody.domain.repository.ody - -interface FCMTokenRepository { - suspend fun fetchFCMToken(): Result - - suspend fun postFCMToken(fcmToken: String) -} From 504d229bc9a75af689ddebaaf7a859ee0315e090 Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Thu, 19 Dec 2024 23:14:02 +0900 Subject: [PATCH 03/12] =?UTF-8?q?refactor:=20RemoteAuthDataSource=EB=A1=9C?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/DefaultRemoteAuthDataSource.kt | 63 +++++++++++++++++++ .../data/auth/source/RemoteAuthDataSource.kt | 17 +++++ 2 files changed, 80 insertions(+) create mode 100644 android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt create mode 100644 android/app/src/main/java/com/mulberry/ody/data/auth/source/RemoteAuthDataSource.kt diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt new file mode 100644 index 000000000..1c58c2419 --- /dev/null +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt @@ -0,0 +1,63 @@ +package com.mulberry.ody.data.auth.source + +import android.content.Context +import com.mulberry.ody.data.remote.core.entity.login.mapper.toAuthToken +import com.mulberry.ody.data.remote.core.entity.login.request.LoginRequest +import com.mulberry.ody.data.remote.core.service.LoginService +import com.mulberry.ody.data.remote.core.service.LogoutService +import com.mulberry.ody.data.remote.core.service.MemberService +import com.mulberry.ody.data.remote.core.service.RefreshTokenService +import com.mulberry.ody.data.remote.thirdparty.login.kakao.KakaoOAuthLoginService +import com.mulberry.ody.domain.apiresult.ApiResult +import com.mulberry.ody.domain.apiresult.flatMap +import com.mulberry.ody.domain.apiresult.map +import com.mulberry.ody.domain.apiresult.toApiResult +import com.mulberry.ody.domain.model.AuthToken +import javax.inject.Inject + +class DefaultRemoteAuthDataSource +@Inject constructor( + private val loginService: LoginService, + private val logoutService: LogoutService, + private val memberService: MemberService, + private val refreshTokenService: RefreshTokenService, + private val kakaoOAuthLoginService: KakaoOAuthLoginService, +) : RemoteAuthDataSource { + override suspend fun checkIfLoggedIn(): Boolean { + return kakaoOAuthLoginService.checkIfLoggedIn() + } + + override suspend fun postAuthToken(): ApiResult { + return refreshTokenService.postRefreshToken().map { it.toAuthToken() } + } + + override suspend fun login(fcmToken: String, context: Context): ApiResult { + val loginResult = kakaoOAuthLoginService.login(context).toApiResult().map { + LoginRequest( + fcmToken, + it.providerId, + it.nickname, + it.imageUrl, + ) + } + return loginResult.flatMap { loginRequest -> + loginService.postLoginWithKakao(loginRequest).map { it.toAuthToken() } + } + } + + override suspend fun logout(): ApiResult { + val kakaoLogoutResult = kakaoOAuthLoginService.logout() + val odyLogoutResult = logoutService.postLogout() + + val exception = kakaoLogoutResult.exceptionOrNull() + if (exception != null) { + return ApiResult.Unexpected(exception) + } + + return odyLogoutResult + } + + override suspend fun withdraw(): ApiResult { + return memberService.deleteMember() + } +} diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/RemoteAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/RemoteAuthDataSource.kt new file mode 100644 index 000000000..720046e63 --- /dev/null +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/RemoteAuthDataSource.kt @@ -0,0 +1,17 @@ +package com.mulberry.ody.data.auth.source + +import android.content.Context +import com.mulberry.ody.domain.apiresult.ApiResult +import com.mulberry.ody.domain.model.AuthToken + +interface RemoteAuthDataSource { + suspend fun checkIfLoggedIn(): Boolean + + suspend fun postAuthToken(): ApiResult + + suspend fun login(fcmToken: String, context: Context): ApiResult + + suspend fun logout(): ApiResult + + suspend fun withdraw(): ApiResult +} From fa0813e180afa98710bf5a15891848309fefe542 Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Thu, 19 Dec 2024 23:14:24 +0900 Subject: [PATCH 04/12] =?UTF-8?q?refactor:=20LoginRepository=EB=A5=BC=20da?= =?UTF-8?q?ta=20source=20=EC=82=AC=EC=9A=A9=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ody/data/auth/KakaoLoginRepository.kt | 95 ++++--------------- .../domain/apiresult/ApiResultExtensions.kt | 9 ++ 2 files changed, 30 insertions(+), 74 deletions(-) diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoLoginRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoLoginRepository.kt index 97cb9c72e..fafa46ccb 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoLoginRepository.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoLoginRepository.kt @@ -1,101 +1,48 @@ package com.mulberry.ody.data.auth import android.content.Context -import com.mulberry.ody.data.remote.core.entity.login.mapper.toAuthToken -import com.mulberry.ody.data.remote.core.entity.login.request.LoginRequest -import com.mulberry.ody.data.remote.core.service.LoginService -import com.mulberry.ody.data.remote.core.service.LogoutService -import com.mulberry.ody.data.remote.core.service.MemberService -import com.mulberry.ody.data.remote.core.service.RefreshTokenService -import com.mulberry.ody.data.remote.thirdparty.login.entity.UserProfile -import com.mulberry.ody.data.remote.thirdparty.login.kakao.KakaoOAuthLoginService +import com.mulberry.ody.data.auth.source.LocalAuthDataSource +import com.mulberry.ody.data.auth.source.RemoteAuthDataSource import com.mulberry.ody.domain.apiresult.ApiResult -import com.mulberry.ody.domain.apiresult.map +import com.mulberry.ody.domain.apiresult.getOrNull import com.mulberry.ody.domain.apiresult.suspendOnSuccess -import com.mulberry.ody.domain.common.flatMap import com.mulberry.ody.domain.model.AuthToken -import com.mulberry.ody.domain.repository.ody.AuthTokenRepository -import com.mulberry.ody.domain.repository.ody.FCMTokenRepository import com.mulberry.ody.domain.repository.ody.LoginRepository import javax.inject.Inject class KakaoLoginRepository @Inject constructor( - private val loginService: LoginService, - private val logoutService: LogoutService, - private val memberService: MemberService, - private val refreshTokenService: RefreshTokenService, - private val authTokenRepository: AuthTokenRepository, - private val kakaoOAuthLoginService: KakaoOAuthLoginService, - private val fcmTokenRepository: FCMTokenRepository, + private val localAuthDataSource: LocalAuthDataSource, + private val remoteAuthDataSource: RemoteAuthDataSource, ) : LoginRepository { override suspend fun checkIfLoggedIn(): Boolean { - val isKakaoLoggedIn = kakaoOAuthLoginService.checkIfLoggedIn() - val isOdyLoggedIn = - authTokenRepository.fetchAuthToken().getOrNull() != null && - refreshAuthToken().isSuccess - - return isKakaoLoggedIn && isOdyLoggedIn + if (!remoteAuthDataSource.checkIfLoggedIn()) { + return false + } + if (localAuthDataSource.fetchAuthToken().getOrNull() == null) { + return false + } + val authToken = remoteAuthDataSource.postAuthToken().getOrNull() ?: return false + localAuthDataSource.postAuthToken(authToken) + return true } - private suspend fun refreshAuthToken(): ApiResult = - refreshTokenService.postRefreshToken() - .map { it.toAuthToken() } - .suspendOnSuccess { - authTokenRepository.setAuthToken(it) - } - override suspend fun login(context: Context): ApiResult { - val loginRequest = kakaoOAuthLoginService.login(context).flatMap { buildLoginRequest(it) } - - if (loginRequest.isFailure) { - val loginRequestException = - loginRequest.exceptionOrNull() ?: Exception("LoginRequest exception이 null입니다") - return ApiResult.Unexpected(loginRequestException) - } - - val result = - loginRequest.getOrNull() ?: return ApiResult.Unexpected( - Exception("LoginRequest 가 null 입니다"), - ) - - return loginService.postLoginWithKakao(result).map { - val token = it.toAuthToken() - authTokenRepository.setAuthToken(token) - token + val fcmToken = localAuthDataSource.fetchFCMToken().getOrNull() ?: return ApiResult.Unexpected(Exception()) + return remoteAuthDataSource.login(fcmToken, context).suspendOnSuccess { + localAuthDataSource.postAuthToken(it) } } override suspend fun logout(): ApiResult { - val kakaoLogoutRequest = kakaoOAuthLoginService.logout() - val logoutRequest = logoutService.postLogout() - authTokenRepository.removeAuthToken() - - if (kakaoLogoutRequest.isFailure) { - val exception = - kakaoLogoutRequest.exceptionOrNull() ?: return ApiResult.Unexpected( - Exception("kakaoLogoutRequest가 null입니다"), - ) - return ApiResult.Unexpected(exception) - } - - return logoutRequest + localAuthDataSource.removeAuthToken() + return remoteAuthDataSource.logout() } - private suspend fun buildLoginRequest(userProfile: UserProfile): Result = - fcmTokenRepository.fetchFCMToken().map { deviceToken -> - LoginRequest( - deviceToken, - userProfile.providerId, - userProfile.nickname, - userProfile.imageUrl, - ) - } - override suspend fun withdrawAccount(): ApiResult { - return memberService.deleteMember().also { - if (it.isSuccess) authTokenRepository.removeAuthToken() + return remoteAuthDataSource.withdraw().suspendOnSuccess { + localAuthDataSource.removeAuthToken() } } } diff --git a/android/app/src/main/java/com/mulberry/ody/domain/apiresult/ApiResultExtensions.kt b/android/app/src/main/java/com/mulberry/ody/domain/apiresult/ApiResultExtensions.kt index ef7fbc34b..e3216a9c7 100644 --- a/android/app/src/main/java/com/mulberry/ody/domain/apiresult/ApiResultExtensions.kt +++ b/android/app/src/main/java/com/mulberry/ody/domain/apiresult/ApiResultExtensions.kt @@ -106,3 +106,12 @@ suspend fun ApiResult.suspendFold( else -> onFailure(exception) } } + +suspend fun ApiResult.flatMap(block: suspend (T) -> ApiResult): ApiResult { + return when (this) { + is ApiResult.Success -> block(this.data) + is ApiResult.Failure -> ApiResult.Failure(this.code, this.errorMessage) + is ApiResult.NetworkError -> ApiResult.NetworkError(this.exception) + is ApiResult.Unexpected -> ApiResult.Unexpected(this.t) + } +} From 3694192eccd353082a311f246fc4218077affbe4 Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Thu, 19 Dec 2024 23:14:51 +0900 Subject: [PATCH 05/12] =?UTF-8?q?style:=20ktLint=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/source/DefaultLocalAuthDataSource.kt | 36 ++++----- .../source/DefaultRemoteAuthDataSource.kt | 79 ++++++++++--------- .../data/auth/source/LocalAuthDataSource.kt | 10 +-- .../data/auth/source/RemoteAuthDataSource.kt | 5 +- .../com/mulberry/ody/di/RepositoryModule.kt | 2 +- 5 files changed, 70 insertions(+), 62 deletions(-) diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultLocalAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultLocalAuthDataSource.kt index 59cfad870..4c6c2871b 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultLocalAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultLocalAuthDataSource.kt @@ -6,25 +6,25 @@ import kotlinx.coroutines.flow.first import javax.inject.Inject class DefaultLocalAuthDataSource -@Inject -constructor( - private val odyDatastore: OdyDatastore, -) : LocalAuthDataSource { - override suspend fun fetchAuthToken(): Result { - return odyDatastore.getAuthToken().first() - } + @Inject + constructor( + private val odyDatastore: OdyDatastore, + ) : LocalAuthDataSource { + override suspend fun fetchAuthToken(): Result { + return odyDatastore.getAuthToken().first() + } - override suspend fun removeAuthToken() { - odyDatastore.removeAuthToken() - } + override suspend fun removeAuthToken() { + odyDatastore.removeAuthToken() + } - override suspend fun postAuthToken(authToken: AuthToken) { - odyDatastore.setAuthToken(authToken) - } + override suspend fun postAuthToken(authToken: AuthToken) { + odyDatastore.setAuthToken(authToken) + } - override suspend fun fetchFCMToken(): Result { - return odyDatastore.getFCMToken().first() - } + override suspend fun fetchFCMToken(): Result { + return odyDatastore.getFCMToken().first() + } - override suspend fun postFCMToken(fcmToken: String) = odyDatastore.setFCMToken(fcmToken) -} + override suspend fun postFCMToken(fcmToken: String) = odyDatastore.setFCMToken(fcmToken) + } diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt index 1c58c2419..bd21d5d12 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt @@ -16,48 +16,53 @@ import com.mulberry.ody.domain.model.AuthToken import javax.inject.Inject class DefaultRemoteAuthDataSource -@Inject constructor( - private val loginService: LoginService, - private val logoutService: LogoutService, - private val memberService: MemberService, - private val refreshTokenService: RefreshTokenService, - private val kakaoOAuthLoginService: KakaoOAuthLoginService, -) : RemoteAuthDataSource { - override suspend fun checkIfLoggedIn(): Boolean { - return kakaoOAuthLoginService.checkIfLoggedIn() - } - - override suspend fun postAuthToken(): ApiResult { - return refreshTokenService.postRefreshToken().map { it.toAuthToken() } - } + @Inject + constructor( + private val loginService: LoginService, + private val logoutService: LogoutService, + private val memberService: MemberService, + private val refreshTokenService: RefreshTokenService, + private val kakaoOAuthLoginService: KakaoOAuthLoginService, + ) : RemoteAuthDataSource { + override suspend fun checkIfLoggedIn(): Boolean { + return kakaoOAuthLoginService.checkIfLoggedIn() + } - override suspend fun login(fcmToken: String, context: Context): ApiResult { - val loginResult = kakaoOAuthLoginService.login(context).toApiResult().map { - LoginRequest( - fcmToken, - it.providerId, - it.nickname, - it.imageUrl, - ) + override suspend fun postAuthToken(): ApiResult { + return refreshTokenService.postRefreshToken().map { it.toAuthToken() } } - return loginResult.flatMap { loginRequest -> - loginService.postLoginWithKakao(loginRequest).map { it.toAuthToken() } + + override suspend fun login( + fcmToken: String, + context: Context, + ): ApiResult { + val loginResult = + kakaoOAuthLoginService.login(context).toApiResult().map { + LoginRequest( + fcmToken, + it.providerId, + it.nickname, + it.imageUrl, + ) + } + return loginResult.flatMap { loginRequest -> + loginService.postLoginWithKakao(loginRequest).map { it.toAuthToken() } + } } - } - override suspend fun logout(): ApiResult { - val kakaoLogoutResult = kakaoOAuthLoginService.logout() - val odyLogoutResult = logoutService.postLogout() + override suspend fun logout(): ApiResult { + val kakaoLogoutResult = kakaoOAuthLoginService.logout() + val odyLogoutResult = logoutService.postLogout() - val exception = kakaoLogoutResult.exceptionOrNull() - if (exception != null) { - return ApiResult.Unexpected(exception) - } + val exception = kakaoLogoutResult.exceptionOrNull() + if (exception != null) { + return ApiResult.Unexpected(exception) + } - return odyLogoutResult - } + return odyLogoutResult + } - override suspend fun withdraw(): ApiResult { - return memberService.deleteMember() + override suspend fun withdraw(): ApiResult { + return memberService.deleteMember() + } } -} diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/LocalAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/LocalAuthDataSource.kt index f0761f32d..d6df25a5d 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/LocalAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/LocalAuthDataSource.kt @@ -3,13 +3,13 @@ package com.mulberry.ody.data.auth.source import com.mulberry.ody.domain.model.AuthToken interface LocalAuthDataSource { - suspend fun fetchAuthToken(): Result + suspend fun fetchAuthToken(): Result - suspend fun removeAuthToken() + suspend fun removeAuthToken() - suspend fun postAuthToken(authToken: AuthToken) + suspend fun postAuthToken(authToken: AuthToken) - suspend fun fetchFCMToken(): Result + suspend fun fetchFCMToken(): Result - suspend fun postFCMToken(fcmToken: String) + suspend fun postFCMToken(fcmToken: String) } diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/RemoteAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/RemoteAuthDataSource.kt index 720046e63..71611e029 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/RemoteAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/RemoteAuthDataSource.kt @@ -9,7 +9,10 @@ interface RemoteAuthDataSource { suspend fun postAuthToken(): ApiResult - suspend fun login(fcmToken: String, context: Context): ApiResult + suspend fun login( + fcmToken: String, + context: Context, + ): ApiResult suspend fun logout(): ApiResult diff --git a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt index 0be75cd9e..1c0bbd9f4 100644 --- a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt +++ b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt @@ -1,5 +1,6 @@ package com.mulberry.ody.di +import com.mulberry.ody.data.auth.KakaoLoginRepository import com.mulberry.ody.data.local.repository.DefaultAuthTokenRepository import com.mulberry.ody.data.local.repository.DefaultMatesEtaRepository import com.mulberry.ody.data.remote.core.repository.DefaultFCMTokenRepository @@ -7,7 +8,6 @@ import com.mulberry.ody.data.remote.core.repository.DefaultJoinRepository import com.mulberry.ody.data.remote.core.repository.DefaultMeetingRepository import com.mulberry.ody.data.remote.core.repository.DefaultNotificationLogRepository import com.mulberry.ody.data.remote.thirdparty.address.KakaoAddressRepository -import com.mulberry.ody.data.auth.KakaoLoginRepository import com.mulberry.ody.domain.repository.location.AddressRepository import com.mulberry.ody.domain.repository.ody.AuthTokenRepository import com.mulberry.ody.domain.repository.ody.FCMTokenRepository From 2eaab1470b332195af8d99f57caa0b1af1cee328 Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Sat, 21 Dec 2024 13:34:27 +0900 Subject: [PATCH 06/12] =?UTF-8?q?fix:=20repository=20=EC=B0=B8=EC=A1=B0=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/DefaultAuthTokenRepository.kt | 25 +++++++++++++++++++ .../repository/DefaultFCMTokenRepository.kt | 18 +++++++++++++ .../com/mulberry/ody/di/RepositoryModule.kt | 2 +- .../repository/ody/AuthTokenRepository.kt | 11 ++++++++ .../repository/ody/FCMTokenRepository.kt | 7 ++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt create mode 100644 android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt create mode 100644 android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt create mode 100644 android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt diff --git a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt new file mode 100644 index 000000000..fe8724af6 --- /dev/null +++ b/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt @@ -0,0 +1,25 @@ +package com.mulberry.ody.data.local.repository + +import com.mulberry.ody.data.local.db.OdyDatastore +import com.mulberry.ody.domain.model.AuthToken +import com.mulberry.ody.domain.repository.ody.AuthTokenRepository +import kotlinx.coroutines.flow.first +import javax.inject.Inject + +class DefaultAuthTokenRepository +@Inject +constructor( + private val odyDatastore: OdyDatastore, +) : AuthTokenRepository { + override suspend fun fetchAuthToken(): Result { + return odyDatastore.getAuthToken().first() + } + + override suspend fun removeAuthToken() { + odyDatastore.removeAuthToken() + } + + override suspend fun setAuthToken(authToken: AuthToken) { + odyDatastore.setAuthToken(authToken) + } +} diff --git a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt new file mode 100644 index 000000000..8d32c0c8a --- /dev/null +++ b/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt @@ -0,0 +1,18 @@ +package com.mulberry.ody.data.local.repository + +import com.mulberry.ody.data.local.db.OdyDatastore +import com.mulberry.ody.domain.repository.ody.FCMTokenRepository +import kotlinx.coroutines.flow.first +import javax.inject.Inject + +class DefaultFCMTokenRepository +@Inject +constructor( + private val odyDatastore: OdyDatastore, +) : FCMTokenRepository { + override suspend fun fetchFCMToken(): Result { + return odyDatastore.getFCMToken().first() + } + + override suspend fun postFCMToken(fcmToken: String) = odyDatastore.setFCMToken(fcmToken) +} diff --git a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt index 1c0bbd9f4..19120b623 100644 --- a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt +++ b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt @@ -2,8 +2,8 @@ package com.mulberry.ody.di import com.mulberry.ody.data.auth.KakaoLoginRepository import com.mulberry.ody.data.local.repository.DefaultAuthTokenRepository +import com.mulberry.ody.data.local.repository.DefaultFCMTokenRepository import com.mulberry.ody.data.local.repository.DefaultMatesEtaRepository -import com.mulberry.ody.data.remote.core.repository.DefaultFCMTokenRepository import com.mulberry.ody.data.remote.core.repository.DefaultJoinRepository import com.mulberry.ody.data.remote.core.repository.DefaultMeetingRepository import com.mulberry.ody.data.remote.core.repository.DefaultNotificationLogRepository diff --git a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt new file mode 100644 index 000000000..cac5935f9 --- /dev/null +++ b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt @@ -0,0 +1,11 @@ +package com.mulberry.ody.domain.repository.ody + +import com.mulberry.ody.domain.model.AuthToken + +interface AuthTokenRepository { + suspend fun fetchAuthToken(): Result + + suspend fun removeAuthToken() + + suspend fun setAuthToken(authToken: AuthToken) +} diff --git a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt new file mode 100644 index 000000000..df3004a02 --- /dev/null +++ b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt @@ -0,0 +1,7 @@ +package com.mulberry.ody.domain.repository.ody + +interface FCMTokenRepository { + suspend fun fetchFCMToken(): Result + + suspend fun postFCMToken(fcmToken: String) +} From f51be6e8808b983858264c3a77be7a608a09ba21 Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Sat, 21 Dec 2024 13:34:55 +0900 Subject: [PATCH 07/12] =?UTF-8?q?feat:=20data=20source=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=84=B1=20=EB=AA=A8=EB=93=88=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mulberry/ody/di/DataSourceModule.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt diff --git a/android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt b/android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt new file mode 100644 index 000000000..ff56850b5 --- /dev/null +++ b/android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt @@ -0,0 +1,23 @@ +package com.mulberry.ody.di + +import com.mulberry.ody.data.auth.source.DefaultLocalAuthDataSource +import com.mulberry.ody.data.auth.source.DefaultRemoteAuthDataSource +import com.mulberry.ody.data.auth.source.LocalAuthDataSource +import com.mulberry.ody.data.auth.source.RemoteAuthDataSource +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +interface DataSourceModule { + @Binds + @Singleton + fun bindRemoteAuthDataSource(defaultRemoteAuthDataSource: DefaultRemoteAuthDataSource): RemoteAuthDataSource + + @Binds + @Singleton + fun bindLocalAuthDataSource(defaultLocalAuthDataSource: DefaultLocalAuthDataSource): LocalAuthDataSource +} From 57395def7ccefda409977837dbfb6f24953d4af3 Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Sat, 21 Dec 2024 13:38:59 +0900 Subject: [PATCH 08/12] =?UTF-8?q?chore:=20LoginRepository=20->=20AuthRepos?= =?UTF-8?q?itory=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...inRepository.kt => KakaoAuthRepository.kt} | 6 ++--- .../source/DefaultRemoteAuthDataSource.kt | 25 ++++++------------- .../{LoginService.kt => AuthService.kt} | 9 ++++++- .../data/remote/core/service/LogoutService.kt | 9 ------- .../data/remote/core/service/MemberService.kt | 9 ------- .../com/mulberry/ody/di/RepositoryModule.kt | 6 ++--- .../java/com/mulberry/ody/di/ServiceModule.kt | 24 +++--------------- .../{LoginRepository.kt => AuthRepository.kt} | 2 +- .../ody/presentation/login/LoginViewModel.kt | 8 +++--- .../presentation/setting/SettingViewModel.kt | 8 +++--- 10 files changed, 34 insertions(+), 72 deletions(-) rename android/app/src/main/java/com/mulberry/ody/data/auth/{KakaoLoginRepository.kt => KakaoAuthRepository.kt} (93%) rename android/app/src/main/java/com/mulberry/ody/data/remote/core/service/{LoginService.kt => AuthService.kt} (68%) delete mode 100644 android/app/src/main/java/com/mulberry/ody/data/remote/core/service/LogoutService.kt delete mode 100644 android/app/src/main/java/com/mulberry/ody/data/remote/core/service/MemberService.kt rename android/app/src/main/java/com/mulberry/ody/domain/repository/ody/{LoginRepository.kt => AuthRepository.kt} (93%) diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoLoginRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoAuthRepository.kt similarity index 93% rename from android/app/src/main/java/com/mulberry/ody/data/auth/KakaoLoginRepository.kt rename to android/app/src/main/java/com/mulberry/ody/data/auth/KakaoAuthRepository.kt index fafa46ccb..f2eb2b469 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoLoginRepository.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoAuthRepository.kt @@ -7,15 +7,15 @@ import com.mulberry.ody.domain.apiresult.ApiResult import com.mulberry.ody.domain.apiresult.getOrNull import com.mulberry.ody.domain.apiresult.suspendOnSuccess import com.mulberry.ody.domain.model.AuthToken -import com.mulberry.ody.domain.repository.ody.LoginRepository +import com.mulberry.ody.domain.repository.ody.AuthRepository import javax.inject.Inject -class KakaoLoginRepository +class KakaoAuthRepository @Inject constructor( private val localAuthDataSource: LocalAuthDataSource, private val remoteAuthDataSource: RemoteAuthDataSource, - ) : LoginRepository { + ) : AuthRepository { override suspend fun checkIfLoggedIn(): Boolean { if (!remoteAuthDataSource.checkIfLoggedIn()) { return false diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt index bd21d5d12..4716cfdf0 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt @@ -3,9 +3,7 @@ package com.mulberry.ody.data.auth.source import android.content.Context import com.mulberry.ody.data.remote.core.entity.login.mapper.toAuthToken import com.mulberry.ody.data.remote.core.entity.login.request.LoginRequest -import com.mulberry.ody.data.remote.core.service.LoginService -import com.mulberry.ody.data.remote.core.service.LogoutService -import com.mulberry.ody.data.remote.core.service.MemberService +import com.mulberry.ody.data.remote.core.service.AuthService import com.mulberry.ody.data.remote.core.service.RefreshTokenService import com.mulberry.ody.data.remote.thirdparty.login.kakao.KakaoOAuthLoginService import com.mulberry.ody.domain.apiresult.ApiResult @@ -18,9 +16,7 @@ import javax.inject.Inject class DefaultRemoteAuthDataSource @Inject constructor( - private val loginService: LoginService, - private val logoutService: LogoutService, - private val memberService: MemberService, + private val authService: AuthService, private val refreshTokenService: RefreshTokenService, private val kakaoOAuthLoginService: KakaoOAuthLoginService, ) : RemoteAuthDataSource { @@ -37,22 +33,17 @@ class DefaultRemoteAuthDataSource context: Context, ): ApiResult { val loginResult = - kakaoOAuthLoginService.login(context).toApiResult().map { - LoginRequest( - fcmToken, - it.providerId, - it.nickname, - it.imageUrl, - ) - } + kakaoOAuthLoginService.login(context).toApiResult() + .map { LoginRequest(fcmToken, it.providerId, it.nickname, it.imageUrl) } + return loginResult.flatMap { loginRequest -> - loginService.postLoginWithKakao(loginRequest).map { it.toAuthToken() } + authService.postLoginWithKakao(loginRequest).map { it.toAuthToken() } } } override suspend fun logout(): ApiResult { val kakaoLogoutResult = kakaoOAuthLoginService.logout() - val odyLogoutResult = logoutService.postLogout() + val odyLogoutResult = authService.postLogout() val exception = kakaoLogoutResult.exceptionOrNull() if (exception != null) { @@ -63,6 +54,6 @@ class DefaultRemoteAuthDataSource } override suspend fun withdraw(): ApiResult { - return memberService.deleteMember() + return authService.deleteMember() } } diff --git a/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/LoginService.kt b/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/AuthService.kt similarity index 68% rename from android/app/src/main/java/com/mulberry/ody/data/remote/core/service/LoginService.kt rename to android/app/src/main/java/com/mulberry/ody/data/remote/core/service/AuthService.kt index 1f407a380..c216947df 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/LoginService.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/AuthService.kt @@ -4,11 +4,18 @@ import com.mulberry.ody.data.remote.core.entity.login.request.LoginRequest import com.mulberry.ody.data.remote.core.entity.login.response.LoginResponse import com.mulberry.ody.domain.apiresult.ApiResult import retrofit2.http.Body +import retrofit2.http.DELETE import retrofit2.http.POST -interface LoginService { +interface AuthService { @POST("/v1/auth/kakao") suspend fun postLoginWithKakao( @Body loginRequest: LoginRequest, ): ApiResult + + @POST("/v1/auth/logout") + suspend fun postLogout(): ApiResult + + @DELETE("/members") + suspend fun deleteMember(): ApiResult } diff --git a/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/LogoutService.kt b/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/LogoutService.kt deleted file mode 100644 index d1e7d6b40..000000000 --- a/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/LogoutService.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.mulberry.ody.data.remote.core.service - -import com.mulberry.ody.domain.apiresult.ApiResult -import retrofit2.http.POST - -interface LogoutService { - @POST("/v1/auth/logout") - suspend fun postLogout(): ApiResult -} diff --git a/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/MemberService.kt b/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/MemberService.kt deleted file mode 100644 index 93d3daa72..000000000 --- a/android/app/src/main/java/com/mulberry/ody/data/remote/core/service/MemberService.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.mulberry.ody.data.remote.core.service - -import com.mulberry.ody.domain.apiresult.ApiResult -import retrofit2.http.DELETE - -interface MemberService { - @DELETE("/members") - suspend fun deleteMember(): ApiResult -} diff --git a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt index 19120b623..98126846a 100644 --- a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt +++ b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt @@ -1,6 +1,6 @@ package com.mulberry.ody.di -import com.mulberry.ody.data.auth.KakaoLoginRepository +import com.mulberry.ody.data.auth.KakaoAuthRepository import com.mulberry.ody.data.local.repository.DefaultAuthTokenRepository import com.mulberry.ody.data.local.repository.DefaultFCMTokenRepository import com.mulberry.ody.data.local.repository.DefaultMatesEtaRepository @@ -12,7 +12,7 @@ import com.mulberry.ody.domain.repository.location.AddressRepository import com.mulberry.ody.domain.repository.ody.AuthTokenRepository import com.mulberry.ody.domain.repository.ody.FCMTokenRepository import com.mulberry.ody.domain.repository.ody.JoinRepository -import com.mulberry.ody.domain.repository.ody.LoginRepository +import com.mulberry.ody.domain.repository.ody.AuthRepository import com.mulberry.ody.domain.repository.ody.MatesEtaRepository import com.mulberry.ody.domain.repository.ody.MeetingRepository import com.mulberry.ody.domain.repository.ody.NotificationLogRepository @@ -47,7 +47,7 @@ interface RepositoryModule { @Binds @Singleton - fun bindKakaoLoginRepository(kakaoLoginRepository: KakaoLoginRepository): LoginRepository + fun bindKakaoLoginRepository(kakaoLoginRepository: KakaoAuthRepository): AuthRepository @Binds @Singleton diff --git a/android/app/src/main/java/com/mulberry/ody/di/ServiceModule.kt b/android/app/src/main/java/com/mulberry/ody/di/ServiceModule.kt index 1084000f6..23586c030 100644 --- a/android/app/src/main/java/com/mulberry/ody/di/ServiceModule.kt +++ b/android/app/src/main/java/com/mulberry/ody/di/ServiceModule.kt @@ -1,10 +1,8 @@ package com.mulberry.ody.di +import com.mulberry.ody.data.remote.core.service.AuthService import com.mulberry.ody.data.remote.core.service.JoinService -import com.mulberry.ody.data.remote.core.service.LoginService -import com.mulberry.ody.data.remote.core.service.LogoutService import com.mulberry.ody.data.remote.core.service.MeetingService -import com.mulberry.ody.data.remote.core.service.MemberService import com.mulberry.ody.data.remote.core.service.NotificationService import com.mulberry.ody.data.remote.core.service.RefreshTokenService import com.mulberry.ody.data.remote.thirdparty.address.KakaoAddressService @@ -32,8 +30,8 @@ object ServiceModule { @Singleton fun provideLoginService( @LoginRetrofit retrofit: Retrofit, - ): LoginService { - return retrofit.create(LoginService::class.java) + ): AuthService { + return retrofit.create(AuthService::class.java) } @Provides @@ -52,14 +50,6 @@ object ServiceModule { return retrofit.create(JoinService::class.java) } - @Provides - @Singleton - fun provideMemberService( - @DefaultRetrofit retrofit: Retrofit, - ): MemberService { - return retrofit.create(MemberService::class.java) - } - @Provides @Singleton fun provideMeetingService( @@ -68,14 +58,6 @@ object ServiceModule { return retrofit.create(MeetingService::class.java) } - @Provides - @Singleton - fun provideLogoutService( - @DefaultRetrofit retrofit: Retrofit, - ): LogoutService { - return retrofit.create(LogoutService::class.java) - } - @Provides @Singleton fun provideNotificationService( diff --git a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/LoginRepository.kt b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthRepository.kt similarity index 93% rename from android/app/src/main/java/com/mulberry/ody/domain/repository/ody/LoginRepository.kt rename to android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthRepository.kt index 6250e9768..197cfaada 100644 --- a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/LoginRepository.kt +++ b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthRepository.kt @@ -4,7 +4,7 @@ import android.content.Context import com.mulberry.ody.domain.apiresult.ApiResult import com.mulberry.ody.domain.model.AuthToken -interface LoginRepository { +interface AuthRepository { suspend fun checkIfLoggedIn(): Boolean suspend fun login(context: Context): ApiResult diff --git a/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginViewModel.kt b/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginViewModel.kt index d023dbe3b..5403b0b40 100644 --- a/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginViewModel.kt +++ b/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginViewModel.kt @@ -6,7 +6,7 @@ import androidx.lifecycle.viewModelScope import com.mulberry.ody.domain.apiresult.onFailure import com.mulberry.ody.domain.apiresult.onNetworkError import com.mulberry.ody.domain.apiresult.suspendOnSuccess -import com.mulberry.ody.domain.repository.ody.LoginRepository +import com.mulberry.ody.domain.repository.ody.AuthRepository import com.mulberry.ody.domain.repository.ody.MatesEtaRepository import com.mulberry.ody.presentation.common.BaseViewModel import com.mulberry.ody.presentation.common.analytics.AnalyticsHelper @@ -23,7 +23,7 @@ class LoginViewModel @Inject constructor( private val analyticsHelper: AnalyticsHelper, - private val loginRepository: LoginRepository, + private val authRepository: AuthRepository, private val savedStateHandle: SavedStateHandle, private val matesEtaRepository: MatesEtaRepository, ) : BaseViewModel() { @@ -45,7 +45,7 @@ class LoginViewModel fun checkIfLoggedIn() { viewModelScope.launch { - if (loginRepository.checkIfLoggedIn()) { + if (authRepository.checkIfLoggedIn()) { navigateToMeetings() } } @@ -54,7 +54,7 @@ class LoginViewModel fun loginWithKakao(context: Context) { viewModelScope.launch { startLoading() - loginRepository.login(context) + authRepository.login(context) .suspendOnSuccess { navigateToMeetings() matesEtaRepository.reserveAllEtaReservation() diff --git a/android/app/src/main/java/com/mulberry/ody/presentation/setting/SettingViewModel.kt b/android/app/src/main/java/com/mulberry/ody/presentation/setting/SettingViewModel.kt index a93b89a81..85c0ff0b7 100644 --- a/android/app/src/main/java/com/mulberry/ody/presentation/setting/SettingViewModel.kt +++ b/android/app/src/main/java/com/mulberry/ody/presentation/setting/SettingViewModel.kt @@ -4,7 +4,7 @@ import androidx.lifecycle.viewModelScope import com.mulberry.ody.domain.apiresult.onFailure import com.mulberry.ody.domain.apiresult.onNetworkError import com.mulberry.ody.domain.apiresult.suspendOnSuccess -import com.mulberry.ody.domain.repository.ody.LoginRepository +import com.mulberry.ody.domain.repository.ody.AuthRepository import com.mulberry.ody.domain.repository.ody.MatesEtaRepository import com.mulberry.ody.presentation.common.BaseViewModel import com.mulberry.ody.presentation.common.analytics.AnalyticsHelper @@ -23,7 +23,7 @@ class SettingViewModel @Inject constructor( private val analyticsHelper: AnalyticsHelper, - private val loginRepository: LoginRepository, + private val authRepository: AuthRepository, private val matesEtaRepository: MatesEtaRepository, ) : BaseViewModel() { private val _loginNavigateEvent: MutableSharedFlow = @@ -32,7 +32,7 @@ class SettingViewModel fun logout() { viewModelScope.launch { - loginRepository.logout() + authRepository.logout() _loginNavigateEvent.emit(LoginNavigatedReason.LOGOUT) matesEtaRepository.clearEtaReservation(isReservationPending = true) } @@ -41,7 +41,7 @@ class SettingViewModel fun withdrawAccount() { viewModelScope.launch { startLoading() - loginRepository.withdrawAccount() + authRepository.withdrawAccount() .suspendOnSuccess { _loginNavigateEvent.emit(LoginNavigatedReason.WITHDRAWAL) matesEtaRepository.clearEtaFetchingJob() From a99f45a40c0d91f40335058d0707bbc9a3e56e3e Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Sat, 21 Dec 2024 13:40:31 +0900 Subject: [PATCH 09/12] =?UTF-8?q?chore:=20auth=20=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => repository}/KakaoAuthRepository.kt | 6 ++--- .../{ => local}/DefaultLocalAuthDataSource.kt | 2 +- .../source/{ => local}/LocalAuthDataSource.kt | 2 +- .../DefaultRemoteAuthDataSource.kt | 2 +- .../{ => remote}/RemoteAuthDataSource.kt | 2 +- .../repository/DefaultAuthTokenRepository.kt | 26 +++++++++---------- .../repository/DefaultFCMTokenRepository.kt | 18 ++++++------- .../com/mulberry/ody/di/DataSourceModule.kt | 8 +++--- .../com/mulberry/ody/di/RepositoryModule.kt | 4 +-- 9 files changed, 35 insertions(+), 35 deletions(-) rename android/app/src/main/java/com/mulberry/ody/data/auth/{ => repository}/KakaoAuthRepository.kt (90%) rename android/app/src/main/java/com/mulberry/ody/data/auth/source/{ => local}/DefaultLocalAuthDataSource.kt (94%) rename android/app/src/main/java/com/mulberry/ody/data/auth/source/{ => local}/LocalAuthDataSource.kt (86%) rename android/app/src/main/java/com/mulberry/ody/data/auth/source/{ => remote}/DefaultRemoteAuthDataSource.kt (97%) rename android/app/src/main/java/com/mulberry/ody/data/auth/source/{ => remote}/RemoteAuthDataSource.kt (90%) diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoAuthRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/repository/KakaoAuthRepository.kt similarity index 90% rename from android/app/src/main/java/com/mulberry/ody/data/auth/KakaoAuthRepository.kt rename to android/app/src/main/java/com/mulberry/ody/data/auth/repository/KakaoAuthRepository.kt index f2eb2b469..c8f87455f 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/KakaoAuthRepository.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/repository/KakaoAuthRepository.kt @@ -1,8 +1,8 @@ -package com.mulberry.ody.data.auth +package com.mulberry.ody.data.auth.repository import android.content.Context -import com.mulberry.ody.data.auth.source.LocalAuthDataSource -import com.mulberry.ody.data.auth.source.RemoteAuthDataSource +import com.mulberry.ody.data.auth.source.local.LocalAuthDataSource +import com.mulberry.ody.data.auth.source.remote.RemoteAuthDataSource import com.mulberry.ody.domain.apiresult.ApiResult import com.mulberry.ody.domain.apiresult.getOrNull import com.mulberry.ody.domain.apiresult.suspendOnSuccess diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultLocalAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/DefaultLocalAuthDataSource.kt similarity index 94% rename from android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultLocalAuthDataSource.kt rename to android/app/src/main/java/com/mulberry/ody/data/auth/source/local/DefaultLocalAuthDataSource.kt index 4c6c2871b..6166153b7 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultLocalAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/DefaultLocalAuthDataSource.kt @@ -1,4 +1,4 @@ -package com.mulberry.ody.data.auth.source +package com.mulberry.ody.data.auth.source.local import com.mulberry.ody.data.local.db.OdyDatastore import com.mulberry.ody.domain.model.AuthToken diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/LocalAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/LocalAuthDataSource.kt similarity index 86% rename from android/app/src/main/java/com/mulberry/ody/data/auth/source/LocalAuthDataSource.kt rename to android/app/src/main/java/com/mulberry/ody/data/auth/source/local/LocalAuthDataSource.kt index d6df25a5d..9043bb158 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/LocalAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/LocalAuthDataSource.kt @@ -1,4 +1,4 @@ -package com.mulberry.ody.data.auth.source +package com.mulberry.ody.data.auth.source.local import com.mulberry.ody.domain.model.AuthToken diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/DefaultRemoteAuthDataSource.kt similarity index 97% rename from android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt rename to android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/DefaultRemoteAuthDataSource.kt index 4716cfdf0..2d8c1a8cd 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/DefaultRemoteAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/DefaultRemoteAuthDataSource.kt @@ -1,4 +1,4 @@ -package com.mulberry.ody.data.auth.source +package com.mulberry.ody.data.auth.source.remote import android.content.Context import com.mulberry.ody.data.remote.core.entity.login.mapper.toAuthToken diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/RemoteAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/RemoteAuthDataSource.kt similarity index 90% rename from android/app/src/main/java/com/mulberry/ody/data/auth/source/RemoteAuthDataSource.kt rename to android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/RemoteAuthDataSource.kt index 71611e029..9386df412 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/RemoteAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/RemoteAuthDataSource.kt @@ -1,4 +1,4 @@ -package com.mulberry.ody.data.auth.source +package com.mulberry.ody.data.auth.source.remote import android.content.Context import com.mulberry.ody.domain.apiresult.ApiResult diff --git a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt index fe8724af6..6ecec1cdc 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt @@ -7,19 +7,19 @@ import kotlinx.coroutines.flow.first import javax.inject.Inject class DefaultAuthTokenRepository -@Inject -constructor( - private val odyDatastore: OdyDatastore, -) : AuthTokenRepository { - override suspend fun fetchAuthToken(): Result { - return odyDatastore.getAuthToken().first() - } + @Inject + constructor( + private val odyDatastore: OdyDatastore, + ) : AuthTokenRepository { + override suspend fun fetchAuthToken(): Result { + return odyDatastore.getAuthToken().first() + } - override suspend fun removeAuthToken() { - odyDatastore.removeAuthToken() - } + override suspend fun removeAuthToken() { + odyDatastore.removeAuthToken() + } - override suspend fun setAuthToken(authToken: AuthToken) { - odyDatastore.setAuthToken(authToken) + override suspend fun setAuthToken(authToken: AuthToken) { + odyDatastore.setAuthToken(authToken) + } } -} diff --git a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt index 8d32c0c8a..af03114f2 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt @@ -6,13 +6,13 @@ import kotlinx.coroutines.flow.first import javax.inject.Inject class DefaultFCMTokenRepository -@Inject -constructor( - private val odyDatastore: OdyDatastore, -) : FCMTokenRepository { - override suspend fun fetchFCMToken(): Result { - return odyDatastore.getFCMToken().first() - } + @Inject + constructor( + private val odyDatastore: OdyDatastore, + ) : FCMTokenRepository { + override suspend fun fetchFCMToken(): Result { + return odyDatastore.getFCMToken().first() + } - override suspend fun postFCMToken(fcmToken: String) = odyDatastore.setFCMToken(fcmToken) -} + override suspend fun postFCMToken(fcmToken: String) = odyDatastore.setFCMToken(fcmToken) + } diff --git a/android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt b/android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt index ff56850b5..4e06960ca 100644 --- a/android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt +++ b/android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt @@ -1,9 +1,9 @@ package com.mulberry.ody.di -import com.mulberry.ody.data.auth.source.DefaultLocalAuthDataSource -import com.mulberry.ody.data.auth.source.DefaultRemoteAuthDataSource -import com.mulberry.ody.data.auth.source.LocalAuthDataSource -import com.mulberry.ody.data.auth.source.RemoteAuthDataSource +import com.mulberry.ody.data.auth.source.local.DefaultLocalAuthDataSource +import com.mulberry.ody.data.auth.source.local.LocalAuthDataSource +import com.mulberry.ody.data.auth.source.remote.DefaultRemoteAuthDataSource +import com.mulberry.ody.data.auth.source.remote.RemoteAuthDataSource import dagger.Binds import dagger.Module import dagger.hilt.InstallIn diff --git a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt index 98126846a..b983609f0 100644 --- a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt +++ b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt @@ -1,6 +1,6 @@ package com.mulberry.ody.di -import com.mulberry.ody.data.auth.KakaoAuthRepository +import com.mulberry.ody.data.auth.repository.KakaoAuthRepository import com.mulberry.ody.data.local.repository.DefaultAuthTokenRepository import com.mulberry.ody.data.local.repository.DefaultFCMTokenRepository import com.mulberry.ody.data.local.repository.DefaultMatesEtaRepository @@ -9,10 +9,10 @@ import com.mulberry.ody.data.remote.core.repository.DefaultMeetingRepository import com.mulberry.ody.data.remote.core.repository.DefaultNotificationLogRepository import com.mulberry.ody.data.remote.thirdparty.address.KakaoAddressRepository import com.mulberry.ody.domain.repository.location.AddressRepository +import com.mulberry.ody.domain.repository.ody.AuthRepository import com.mulberry.ody.domain.repository.ody.AuthTokenRepository import com.mulberry.ody.domain.repository.ody.FCMTokenRepository import com.mulberry.ody.domain.repository.ody.JoinRepository -import com.mulberry.ody.domain.repository.ody.AuthRepository import com.mulberry.ody.domain.repository.ody.MatesEtaRepository import com.mulberry.ody.domain.repository.ody.MeetingRepository import com.mulberry.ody.domain.repository.ody.NotificationLogRepository From 7dd12321f6779ab7ff7b78b0125caeede4daa67e Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Sat, 21 Dec 2024 13:50:05 +0900 Subject: [PATCH 10/12] =?UTF-8?q?chore:=20checkIf=EB=A1=9C=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91=ED=95=98=EB=8A=94=20=EB=AA=A8=ED=98=B8=ED=95=9C=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ody/data/auth/repository/KakaoAuthRepository.kt | 9 +++------ .../data/auth/source/local/DefaultLocalAuthDataSource.kt | 4 ++-- .../ody/data/auth/source/local/LocalAuthDataSource.kt | 2 +- .../auth/source/remote/DefaultRemoteAuthDataSource.kt | 4 ++-- .../ody/data/auth/source/remote/RemoteAuthDataSource.kt | 2 +- .../thirdparty/login/kakao/KakaoOAuthLoginService.kt | 2 +- .../mulberry/ody/domain/repository/ody/AuthRepository.kt | 2 +- .../com/mulberry/ody/presentation/login/LoginActivity.kt | 4 ++-- .../mulberry/ody/presentation/login/LoginViewModel.kt | 6 +++--- 9 files changed, 16 insertions(+), 19 deletions(-) diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/repository/KakaoAuthRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/repository/KakaoAuthRepository.kt index c8f87455f..3d27eb546 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/repository/KakaoAuthRepository.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/repository/KakaoAuthRepository.kt @@ -16,11 +16,8 @@ class KakaoAuthRepository private val localAuthDataSource: LocalAuthDataSource, private val remoteAuthDataSource: RemoteAuthDataSource, ) : AuthRepository { - override suspend fun checkIfLoggedIn(): Boolean { - if (!remoteAuthDataSource.checkIfLoggedIn()) { - return false - } - if (localAuthDataSource.fetchAuthToken().getOrNull() == null) { + override suspend fun isLoggedIn(): Boolean { + if (!remoteAuthDataSource.isLoggedIn() || !localAuthDataSource.isLoggedIn()) { return false } val authToken = remoteAuthDataSource.postAuthToken().getOrNull() ?: return false @@ -29,7 +26,7 @@ class KakaoAuthRepository } override suspend fun login(context: Context): ApiResult { - val fcmToken = localAuthDataSource.fetchFCMToken().getOrNull() ?: return ApiResult.Unexpected(Exception()) + val fcmToken = localAuthDataSource.fetchFCMToken().getOrNull() ?: return ApiResult.Unexpected(Exception("FCM 토큰이 존재하지 않습니다.")) return remoteAuthDataSource.login(fcmToken, context).suspendOnSuccess { localAuthDataSource.postAuthToken(it) } diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/DefaultLocalAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/DefaultLocalAuthDataSource.kt index 6166153b7..1a99f8d84 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/DefaultLocalAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/DefaultLocalAuthDataSource.kt @@ -10,8 +10,8 @@ class DefaultLocalAuthDataSource constructor( private val odyDatastore: OdyDatastore, ) : LocalAuthDataSource { - override suspend fun fetchAuthToken(): Result { - return odyDatastore.getAuthToken().first() + override suspend fun isLoggedIn(): Boolean { + return odyDatastore.getAuthToken().first().isSuccess } override suspend fun removeAuthToken() { diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/LocalAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/LocalAuthDataSource.kt index 9043bb158..fff1695af 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/LocalAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/LocalAuthDataSource.kt @@ -3,7 +3,7 @@ package com.mulberry.ody.data.auth.source.local import com.mulberry.ody.domain.model.AuthToken interface LocalAuthDataSource { - suspend fun fetchAuthToken(): Result + suspend fun isLoggedIn(): Boolean suspend fun removeAuthToken() diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/DefaultRemoteAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/DefaultRemoteAuthDataSource.kt index 2d8c1a8cd..964781ba1 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/DefaultRemoteAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/DefaultRemoteAuthDataSource.kt @@ -20,8 +20,8 @@ class DefaultRemoteAuthDataSource private val refreshTokenService: RefreshTokenService, private val kakaoOAuthLoginService: KakaoOAuthLoginService, ) : RemoteAuthDataSource { - override suspend fun checkIfLoggedIn(): Boolean { - return kakaoOAuthLoginService.checkIfLoggedIn() + override suspend fun isLoggedIn(): Boolean { + return kakaoOAuthLoginService.isLoggedIn() } override suspend fun postAuthToken(): ApiResult { diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/RemoteAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/RemoteAuthDataSource.kt index 9386df412..d0f43eb3a 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/RemoteAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/RemoteAuthDataSource.kt @@ -5,7 +5,7 @@ import com.mulberry.ody.domain.apiresult.ApiResult import com.mulberry.ody.domain.model.AuthToken interface RemoteAuthDataSource { - suspend fun checkIfLoggedIn(): Boolean + suspend fun isLoggedIn(): Boolean suspend fun postAuthToken(): ApiResult diff --git a/android/app/src/main/java/com/mulberry/ody/data/remote/thirdparty/login/kakao/KakaoOAuthLoginService.kt b/android/app/src/main/java/com/mulberry/ody/data/remote/thirdparty/login/kakao/KakaoOAuthLoginService.kt index 65fd0160d..b4ddfe87a 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/remote/thirdparty/login/kakao/KakaoOAuthLoginService.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/remote/thirdparty/login/kakao/KakaoOAuthLoginService.kt @@ -27,7 +27,7 @@ class KakaoOAuthLoginService { } } - fun checkIfLoggedIn(): Boolean = TokenManagerProvider.instance.manager.getToken() != null + fun isLoggedIn(): Boolean = TokenManagerProvider.instance.manager.getToken() != null private suspend fun loginWithKakao(context: Context): Result = loginWithKakaoTalk(context).onFailure { error -> diff --git a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthRepository.kt b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthRepository.kt index 197cfaada..47a7da8ae 100644 --- a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthRepository.kt +++ b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthRepository.kt @@ -5,7 +5,7 @@ import com.mulberry.ody.domain.apiresult.ApiResult import com.mulberry.ody.domain.model.AuthToken interface AuthRepository { - suspend fun checkIfLoggedIn(): Boolean + suspend fun isLoggedIn(): Boolean suspend fun login(context: Context): ApiResult diff --git a/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginActivity.kt b/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginActivity.kt index fc93d1e71..07282f814 100644 --- a/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginActivity.kt +++ b/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginActivity.kt @@ -18,8 +18,8 @@ class LoginActivity : BindingActivity(R.layout.activity_lo override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) initializeObserve() - viewModel.checkIfNavigated() - viewModel.checkIfLoggedIn() + viewModel.verifyNavigation() + viewModel.verifyLogin() } override fun initializeBinding() { diff --git a/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginViewModel.kt b/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginViewModel.kt index 5403b0b40..355d4d066 100644 --- a/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginViewModel.kt +++ b/android/app/src/main/java/com/mulberry/ody/presentation/login/LoginViewModel.kt @@ -35,7 +35,7 @@ class LoginViewModel MutableSharedFlow() val navigateAction: SharedFlow get() = _navigateAction.asSharedFlow() - fun checkIfNavigated() { + fun verifyNavigation() { savedStateHandle.get(NAVIGATED_REASON)?.let { reason -> viewModelScope.launch { _navigatedReason.emit(reason) @@ -43,9 +43,9 @@ class LoginViewModel } } - fun checkIfLoggedIn() { + fun verifyLogin() { viewModelScope.launch { - if (authRepository.checkIfLoggedIn()) { + if (authRepository.isLoggedIn()) { navigateToMeetings() } } From dbadd473c39c046b7fd9aa4b841ffd018b0ffc48 Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Sat, 21 Dec 2024 14:21:32 +0900 Subject: [PATCH 11/12] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20repository=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/DefaultAuthTokenRepository.kt | 25 ------------------- .../repository/DefaultFCMTokenRepository.kt | 18 ------------- .../thirdparty/fcm/service/FCMService.kt | 6 ++--- .../data/retrofit/AccessTokenInterceptor.kt | 9 ++++--- .../data/retrofit/RefreshTokenInterceptor.kt | 7 +++--- .../java/com/mulberry/ody/di/NetworkModule.kt | 10 ++++---- .../com/mulberry/ody/di/RepositoryModule.kt | 12 --------- .../repository/ody/AuthTokenRepository.kt | 11 -------- .../repository/ody/FCMTokenRepository.kt | 7 ------ 9 files changed, 17 insertions(+), 88 deletions(-) delete mode 100644 android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt delete mode 100644 android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt delete mode 100644 android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt delete mode 100644 android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt diff --git a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt deleted file mode 100644 index 6ecec1cdc..000000000 --- a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultAuthTokenRepository.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.mulberry.ody.data.local.repository - -import com.mulberry.ody.data.local.db.OdyDatastore -import com.mulberry.ody.domain.model.AuthToken -import com.mulberry.ody.domain.repository.ody.AuthTokenRepository -import kotlinx.coroutines.flow.first -import javax.inject.Inject - -class DefaultAuthTokenRepository - @Inject - constructor( - private val odyDatastore: OdyDatastore, - ) : AuthTokenRepository { - override suspend fun fetchAuthToken(): Result { - return odyDatastore.getAuthToken().first() - } - - override suspend fun removeAuthToken() { - odyDatastore.removeAuthToken() - } - - override suspend fun setAuthToken(authToken: AuthToken) { - odyDatastore.setAuthToken(authToken) - } - } diff --git a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt deleted file mode 100644 index af03114f2..000000000 --- a/android/app/src/main/java/com/mulberry/ody/data/local/repository/DefaultFCMTokenRepository.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.mulberry.ody.data.local.repository - -import com.mulberry.ody.data.local.db.OdyDatastore -import com.mulberry.ody.domain.repository.ody.FCMTokenRepository -import kotlinx.coroutines.flow.first -import javax.inject.Inject - -class DefaultFCMTokenRepository - @Inject - constructor( - private val odyDatastore: OdyDatastore, - ) : FCMTokenRepository { - override suspend fun fetchFCMToken(): Result { - return odyDatastore.getFCMToken().first() - } - - override suspend fun postFCMToken(fcmToken: String) = odyDatastore.setFCMToken(fcmToken) - } diff --git a/android/app/src/main/java/com/mulberry/ody/data/remote/thirdparty/fcm/service/FCMService.kt b/android/app/src/main/java/com/mulberry/ody/data/remote/thirdparty/fcm/service/FCMService.kt index 3399fabbd..d50650a0b 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/remote/thirdparty/fcm/service/FCMService.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/remote/thirdparty/fcm/service/FCMService.kt @@ -2,8 +2,8 @@ package com.mulberry.ody.data.remote.thirdparty.fcm.service import com.google.firebase.messaging.FirebaseMessagingService import com.google.firebase.messaging.RemoteMessage +import com.mulberry.ody.data.local.db.OdyDatastore import com.mulberry.ody.domain.model.NotificationType -import com.mulberry.ody.domain.repository.ody.FCMTokenRepository import com.mulberry.ody.presentation.notification.FCMNotification import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.runBlocking @@ -12,7 +12,7 @@ import javax.inject.Inject @AndroidEntryPoint class FCMService : FirebaseMessagingService() { @Inject - lateinit var fcmTokenRepository: FCMTokenRepository + lateinit var odyDatastore: OdyDatastore @Inject lateinit var fcmNotification: FCMNotification @@ -28,7 +28,7 @@ class FCMService : FirebaseMessagingService() { override fun onNewToken(token: String) { runBlocking { - fcmTokenRepository.postFCMToken(token) + odyDatastore.setFCMToken(token) } } } diff --git a/android/app/src/main/java/com/mulberry/ody/data/retrofit/AccessTokenInterceptor.kt b/android/app/src/main/java/com/mulberry/ody/data/retrofit/AccessTokenInterceptor.kt index 843e028f0..0c22f80aa 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/retrofit/AccessTokenInterceptor.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/retrofit/AccessTokenInterceptor.kt @@ -1,13 +1,14 @@ package com.mulberry.ody.data.retrofit +import com.mulberry.ody.data.local.db.OdyDatastore import com.mulberry.ody.data.remote.core.entity.login.mapper.toAuthToken import com.mulberry.ody.data.remote.core.service.RefreshTokenService import com.mulberry.ody.domain.apiresult.ApiResult import com.mulberry.ody.domain.apiresult.map import com.mulberry.ody.domain.apiresult.suspendOnSuccess import com.mulberry.ody.domain.model.AuthToken -import com.mulberry.ody.domain.repository.ody.AuthTokenRepository import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.first import kotlinx.coroutines.runBlocking import okhttp3.Interceptor import okhttp3.Response @@ -16,7 +17,7 @@ import javax.inject.Inject class AccessTokenInterceptor @Inject constructor( - private val tokenRepository: AuthTokenRepository, + private val odyDatastore: OdyDatastore, private val refreshTokenService: RefreshTokenService, ) : Interceptor { override fun intercept(chain: Interceptor.Chain): Response { @@ -47,7 +48,7 @@ class AccessTokenInterceptor private fun fetchAuthToken(): Result = runBlocking { - tokenRepository.fetchAuthToken() + odyDatastore.getAuthToken().first() } private fun refreshAuthToken(): ApiResult = @@ -55,7 +56,7 @@ class AccessTokenInterceptor refreshTokenService.postRefreshToken() .map { it.toAuthToken() } .suspendOnSuccess { - tokenRepository.setAuthToken(it) + odyDatastore.setAuthToken(it) } } } diff --git a/android/app/src/main/java/com/mulberry/ody/data/retrofit/RefreshTokenInterceptor.kt b/android/app/src/main/java/com/mulberry/ody/data/retrofit/RefreshTokenInterceptor.kt index d3a506a68..e0645a839 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/retrofit/RefreshTokenInterceptor.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/retrofit/RefreshTokenInterceptor.kt @@ -1,7 +1,8 @@ package com.mulberry.ody.data.retrofit +import com.mulberry.ody.data.local.db.OdyDatastore import com.mulberry.ody.domain.model.AuthToken -import com.mulberry.ody.domain.repository.ody.AuthTokenRepository +import kotlinx.coroutines.flow.first import kotlinx.coroutines.runBlocking import okhttp3.Interceptor import okhttp3.Response @@ -10,7 +11,7 @@ import javax.inject.Inject class RefreshTokenInterceptor @Inject constructor( - private val tokenRepository: AuthTokenRepository, + private val odyDatastore: OdyDatastore, ) : Interceptor { override fun intercept(chain: Interceptor.Chain): Response { val token = @@ -26,6 +27,6 @@ class RefreshTokenInterceptor private fun fetchAuthToken(): Result = runBlocking { - tokenRepository.fetchAuthToken() + odyDatastore.getAuthToken().first() } } diff --git a/android/app/src/main/java/com/mulberry/ody/di/NetworkModule.kt b/android/app/src/main/java/com/mulberry/ody/di/NetworkModule.kt index b7584c712..107eb3351 100644 --- a/android/app/src/main/java/com/mulberry/ody/di/NetworkModule.kt +++ b/android/app/src/main/java/com/mulberry/ody/di/NetworkModule.kt @@ -1,11 +1,11 @@ package com.mulberry.ody.di import com.mulberry.ody.BuildConfig +import com.mulberry.ody.data.local.db.OdyDatastore import com.mulberry.ody.data.remote.core.service.RefreshTokenService import com.mulberry.ody.data.retrofit.AccessTokenInterceptor import com.mulberry.ody.data.retrofit.ApiResultCallAdapter import com.mulberry.ody.data.retrofit.RefreshTokenInterceptor -import com.mulberry.ody.domain.repository.ody.AuthTokenRepository import com.squareup.moshi.Moshi import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory import dagger.Module @@ -190,17 +190,17 @@ object NetworkModule { @Singleton @AuthTokenInterceptor fun provideAuthTokenInterceptor( - authTokenRepository: AuthTokenRepository, + odyDatastore: OdyDatastore, refreshTokenService: RefreshTokenService, ): Interceptor { - return AccessTokenInterceptor(authTokenRepository, refreshTokenService) + return AccessTokenInterceptor(odyDatastore, refreshTokenService) } @Provides @Singleton @AuthRefreshTokenInterceptor - fun provideRefreshTokenInterceptor(authTokenRepository: AuthTokenRepository): Interceptor { - return RefreshTokenInterceptor(authTokenRepository) + fun provideRefreshTokenInterceptor(odyDatastore: OdyDatastore): Interceptor { + return RefreshTokenInterceptor(odyDatastore) } @Provides diff --git a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt index b983609f0..f1b0bd13a 100644 --- a/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt +++ b/android/app/src/main/java/com/mulberry/ody/di/RepositoryModule.kt @@ -1,8 +1,6 @@ package com.mulberry.ody.di import com.mulberry.ody.data.auth.repository.KakaoAuthRepository -import com.mulberry.ody.data.local.repository.DefaultAuthTokenRepository -import com.mulberry.ody.data.local.repository.DefaultFCMTokenRepository import com.mulberry.ody.data.local.repository.DefaultMatesEtaRepository import com.mulberry.ody.data.remote.core.repository.DefaultJoinRepository import com.mulberry.ody.data.remote.core.repository.DefaultMeetingRepository @@ -10,8 +8,6 @@ import com.mulberry.ody.data.remote.core.repository.DefaultNotificationLogReposi import com.mulberry.ody.data.remote.thirdparty.address.KakaoAddressRepository import com.mulberry.ody.domain.repository.location.AddressRepository import com.mulberry.ody.domain.repository.ody.AuthRepository -import com.mulberry.ody.domain.repository.ody.AuthTokenRepository -import com.mulberry.ody.domain.repository.ody.FCMTokenRepository import com.mulberry.ody.domain.repository.ody.JoinRepository import com.mulberry.ody.domain.repository.ody.MatesEtaRepository import com.mulberry.ody.domain.repository.ody.MeetingRepository @@ -33,10 +29,6 @@ interface RepositoryModule { @Singleton fun bindMeetingRepository(defaultMeetingRepository: DefaultMeetingRepository): MeetingRepository - @Binds - @Singleton - fun bindFCMTokenRepository(defaultFCMTokenRepository: DefaultFCMTokenRepository): FCMTokenRepository - @Binds @Singleton fun bindEtaRepository(defaultMatesEtaRepository: DefaultMatesEtaRepository): MatesEtaRepository @@ -52,8 +44,4 @@ interface RepositoryModule { @Binds @Singleton fun bindAddressRepository(kakaoGeoLocationRepository: KakaoAddressRepository): AddressRepository - - @Binds - @Singleton - fun bindAuthTokenRepository(defaultAuthTokenRepository: DefaultAuthTokenRepository): AuthTokenRepository } diff --git a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt deleted file mode 100644 index cac5935f9..000000000 --- a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/AuthTokenRepository.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.mulberry.ody.domain.repository.ody - -import com.mulberry.ody.domain.model.AuthToken - -interface AuthTokenRepository { - suspend fun fetchAuthToken(): Result - - suspend fun removeAuthToken() - - suspend fun setAuthToken(authToken: AuthToken) -} diff --git a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt b/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt deleted file mode 100644 index df3004a02..000000000 --- a/android/app/src/main/java/com/mulberry/ody/domain/repository/ody/FCMTokenRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.mulberry.ody.domain.repository.ody - -interface FCMTokenRepository { - suspend fun fetchFCMToken(): Result - - suspend fun postFCMToken(fcmToken: String) -} From 2205bef940e07313ea5e62ea0b6ffc89a3bb6303 Mon Sep 17 00:00:00 2001 From: kimhyemin Date: Wed, 1 Jan 2025 16:11:49 +0900 Subject: [PATCH 12/12] =?UTF-8?q?chore:=20default=20data=20source=20->=20k?= =?UTF-8?q?akao=20=EB=A1=9C=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...LocalAuthDataSource.kt => KakaoLocalAuthDataSource.kt} | 2 +- ...moteAuthDataSource.kt => KakaoRemoteAuthDataSource.kt} | 2 +- .../src/main/java/com/mulberry/ody/di/DataSourceModule.kt | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) rename android/app/src/main/java/com/mulberry/ody/data/auth/source/local/{DefaultLocalAuthDataSource.kt => KakaoLocalAuthDataSource.kt} (96%) rename android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/{DefaultRemoteAuthDataSource.kt => KakaoRemoteAuthDataSource.kt} (98%) diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/DefaultLocalAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/KakaoLocalAuthDataSource.kt similarity index 96% rename from android/app/src/main/java/com/mulberry/ody/data/auth/source/local/DefaultLocalAuthDataSource.kt rename to android/app/src/main/java/com/mulberry/ody/data/auth/source/local/KakaoLocalAuthDataSource.kt index 1a99f8d84..cb313042d 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/DefaultLocalAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/local/KakaoLocalAuthDataSource.kt @@ -5,7 +5,7 @@ import com.mulberry.ody.domain.model.AuthToken import kotlinx.coroutines.flow.first import javax.inject.Inject -class DefaultLocalAuthDataSource +class KakaoLocalAuthDataSource @Inject constructor( private val odyDatastore: OdyDatastore, diff --git a/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/DefaultRemoteAuthDataSource.kt b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/KakaoRemoteAuthDataSource.kt similarity index 98% rename from android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/DefaultRemoteAuthDataSource.kt rename to android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/KakaoRemoteAuthDataSource.kt index 964781ba1..8e6ab801c 100644 --- a/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/DefaultRemoteAuthDataSource.kt +++ b/android/app/src/main/java/com/mulberry/ody/data/auth/source/remote/KakaoRemoteAuthDataSource.kt @@ -13,7 +13,7 @@ import com.mulberry.ody.domain.apiresult.toApiResult import com.mulberry.ody.domain.model.AuthToken import javax.inject.Inject -class DefaultRemoteAuthDataSource +class KakaoRemoteAuthDataSource @Inject constructor( private val authService: AuthService, diff --git a/android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt b/android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt index 4e06960ca..64b4d7b3e 100644 --- a/android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt +++ b/android/app/src/main/java/com/mulberry/ody/di/DataSourceModule.kt @@ -1,8 +1,8 @@ package com.mulberry.ody.di -import com.mulberry.ody.data.auth.source.local.DefaultLocalAuthDataSource +import com.mulberry.ody.data.auth.source.local.KakaoLocalAuthDataSource import com.mulberry.ody.data.auth.source.local.LocalAuthDataSource -import com.mulberry.ody.data.auth.source.remote.DefaultRemoteAuthDataSource +import com.mulberry.ody.data.auth.source.remote.KakaoRemoteAuthDataSource import com.mulberry.ody.data.auth.source.remote.RemoteAuthDataSource import dagger.Binds import dagger.Module @@ -15,9 +15,9 @@ import javax.inject.Singleton interface DataSourceModule { @Binds @Singleton - fun bindRemoteAuthDataSource(defaultRemoteAuthDataSource: DefaultRemoteAuthDataSource): RemoteAuthDataSource + fun bindRemoteAuthDataSource(kakaoRemoteAuthDataSource: KakaoRemoteAuthDataSource): RemoteAuthDataSource @Binds @Singleton - fun bindLocalAuthDataSource(defaultLocalAuthDataSource: DefaultLocalAuthDataSource): LocalAuthDataSource + fun bindLocalAuthDataSource(kakaoLocalAuthDataSource: KakaoLocalAuthDataSource): LocalAuthDataSource }