From 651e6bb9d54f34b9d809a8ba42e61d1fcbf47d7b Mon Sep 17 00:00:00 2001 From: gaeun Date: Sun, 15 Oct 2023 14:00:33 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT/#100]=20=ED=86=A0=ED=81=B0=20=EC=9E=AC?= =?UTF-8?q?=EB=B0=9C=EA=B8=89=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/remote/impl/AuthDataSourceImpl.kt | 12 +++++++++--- .../data/repository/AuthRepositoryImpl.kt | 1 - .../java/com/puzzling/puzzlingaos/di/ApiModule.kt | 6 ++++++ .../presentation/onboarding/LoginActivity.kt | 2 ++ .../presentation/onboarding/LoginViewModel.kt | 4 ---- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/remote/impl/AuthDataSourceImpl.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/remote/impl/AuthDataSourceImpl.kt index 5c169bd..0218140 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/remote/impl/AuthDataSourceImpl.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/remote/impl/AuthDataSourceImpl.kt @@ -5,11 +5,17 @@ import com.puzzling.puzzlingaos.data.model.request.RequestLoginDto import com.puzzling.puzzlingaos.data.model.response.ResponseLoginDto import com.puzzling.puzzlingaos.data.model.response.ResponseTokenDto import com.puzzling.puzzlingaos.data.service.AuthService +import com.puzzling.puzzlingaos.data.service.ReIssueTokenService import javax.inject.Inject -class AuthDataSourceImpl @Inject constructor(private val apiService: AuthService) : AuthDataSource { +class AuthDataSourceImpl @Inject constructor( + private val authService: AuthService, + private val reIssueTokenService: ReIssueTokenService, +) : AuthDataSource { + override suspend fun login(socialPlatform: String): ResponseLoginDto = - apiService.login(RequestLoginDto(socialPlatform)) + authService.login(RequestLoginDto(socialPlatform)) - override suspend fun getToken(): ResponseTokenDto = apiService.getToken() + override suspend fun getToken(): ResponseTokenDto = + reIssueTokenService.getToken() } diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/repository/AuthRepositoryImpl.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/repository/AuthRepositoryImpl.kt index 879480f..b34a9d8 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/repository/AuthRepositoryImpl.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/repository/AuthRepositoryImpl.kt @@ -2,7 +2,6 @@ package com.puzzling.puzzlingaos.data.repository import android.util.Log import androidx.datastore.core.DataStore -import com.puzzling.puzzlingaos.data.datasource.local.UserDataSource import com.puzzling.puzzlingaos.data.datasource.remote.AuthDataSource import com.puzzling.puzzlingaos.data.entity.Token import com.puzzling.puzzlingaos.data.entity.User diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/ApiModule.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/ApiModule.kt index 044b9d8..d34f37c 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/ApiModule.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/ApiModule.kt @@ -4,6 +4,7 @@ import com.puzzling.puzzlingaos.data.service.AuthService import com.puzzling.puzzlingaos.data.service.MyPageService import com.puzzling.puzzlingaos.data.service.PersonalReviewService import com.puzzling.puzzlingaos.data.service.ProjectService +import com.puzzling.puzzlingaos.data.service.ReIssueTokenService import com.puzzling.puzzlingaos.data.service.TeamReviewService import com.puzzling.puzzlingaos.data.service.WriteReviewService import dagger.Module @@ -45,4 +46,9 @@ object ApiModule { @Singleton fun provideAuthService(@PuzzlingRetrofit retrofit: Retrofit): AuthService = retrofit.create(AuthService::class.java) + + @Provides + @Singleton + fun provideReIssueTokenService(@ReIssueRetrofit retrofit: Retrofit): ReIssueTokenService = + retrofit.create(ReIssueTokenService::class.java) } diff --git a/app/src/main/java/com/puzzling/puzzlingaos/presentation/onboarding/LoginActivity.kt b/app/src/main/java/com/puzzling/puzzlingaos/presentation/onboarding/LoginActivity.kt index 150d6a3..113e6cf 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/presentation/onboarding/LoginActivity.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/presentation/onboarding/LoginActivity.kt @@ -2,6 +2,7 @@ package com.puzzling.puzzlingaos.presentation.onboarding import android.content.Intent import android.os.Bundle +import android.util.Log import androidx.activity.viewModels import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope @@ -39,6 +40,7 @@ class LoginActivity : BaseActivity(R.layout.activity_login intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) startActivity(intent) finish() + viewModel.getToken() } } } diff --git a/app/src/main/java/com/puzzling/puzzlingaos/presentation/onboarding/LoginViewModel.kt b/app/src/main/java/com/puzzling/puzzlingaos/presentation/onboarding/LoginViewModel.kt index c29450b..c13737d 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/presentation/onboarding/LoginViewModel.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/presentation/onboarding/LoginViewModel.kt @@ -46,10 +46,6 @@ class LoginViewModel @Inject constructor( }.handleResult(token, error) } - init { - getToken() - } - fun login(socialPlatform: String) = viewModelScope.launch { Log.d("LoginActivity", "로그인 함수 호출") authRepository.login("KAKAO")