From ea3cafa59f40edc274d1b5b9db827c8b034598e8 Mon Sep 17 00:00:00 2001 From: gaeun Date: Fri, 29 Sep 2023 23:54:49 +0900 Subject: [PATCH 01/30] =?UTF-8?q?[FIX/#100]=20Entity=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/puzzling/puzzlingaos/data/entity/Token.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/entity/Token.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/entity/Token.kt index 8e9e57f..cbcdc53 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/entity/Token.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/entity/Token.kt @@ -5,4 +5,5 @@ import kotlinx.serialization.Serializable @Serializable data class Token( val accessToken: String? = null, + val refreshToken: String? = null, ) From 2bc00307ccb9594b693e7826c7363933da18550a Mon Sep 17 00:00:00 2001 From: gaeun Date: Fri, 29 Sep 2023 23:57:46 +0900 Subject: [PATCH 02/30] =?UTF-8?q?[ADD/#100]=20Dto=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/model/response/ResponseLoginDto.kt | 34 +++++++++++++++++++ .../data/model/response/ResponseTokenDto.kt | 23 +++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseTokenDto.kt diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt new file mode 100644 index 0000000..2d8f520 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt @@ -0,0 +1,34 @@ +package com.puzzling.puzzlingaos.data.model.response + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ResponseLoginDto( + @SerialName("status") + val status: String, + @SerialName("success") + val success: Boolean, + @SerialName("message") + val message: String, + @SerialName("data") + val data: LoginData?, + +) { + @Serializable + + data class LoginData( + @SerialName("name") + val name: String, + @SerialName("memberId") + val memberId: Int, + @SerialName("projectId") + val projectId: Int, + @SerialName("accessToken") + val accessToken: String, + @SerialName("refreshToken") + val refreshToken: String, + @SerialName("isNewUser") + val isNewUser: Boolean, + ) +} diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseTokenDto.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseTokenDto.kt new file mode 100644 index 0000000..d298cda --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseTokenDto.kt @@ -0,0 +1,23 @@ +package com.puzzling.puzzlingaos.data.model.response + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ResponseTokenDto( + @SerialName("status") + val status: Int, + @SerialName("success") + val success: Boolean, + @SerialName("message") + val message: String, + @SerialName("date") + val data: NewToken?, +) { + @Serializable + data class NewToken( + @SerialName("accessToken") + val accessToken: String, + + ) +} From 505b161c0d260d24b4a6f5726c3b4f8af5464c66 Mon Sep 17 00:00:00 2001 From: gaeun Date: Fri, 29 Sep 2023 23:57:55 +0900 Subject: [PATCH 03/30] =?UTF-8?q?[ADD/#100]=20Service=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puzzlingaos/data/service/AuthService.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt new file mode 100644 index 0000000..6dabce3 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt @@ -0,0 +1,17 @@ +package com.puzzling.puzzlingaos.data.service + +import com.puzzling.puzzlingaos.data.model.response.ResponseLoginDto +import com.puzzling.puzzlingaos.data.model.response.ResponseTokenDto +import retrofit2.http.Body +import retrofit2.http.GET +import retrofit2.http.POST + +interface AuthService { + @POST("auth") + suspend fun login( + @Body socialPlatform: String, + ): ResponseLoginDto + + @GET("auth/token") + suspend fun getToken(): ResponseTokenDto +} From 91531fb36f58dc1e4deb83c9c48ea434789473ba Mon Sep 17 00:00:00 2001 From: gaeun Date: Sat, 30 Sep 2023 23:59:03 +0900 Subject: [PATCH 04/30] =?UTF-8?q?[ADD/#100]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=20=EA=B4=80=EB=A0=A8=20data=20Entity=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puzzling/puzzlingaos/data/entity/CurrentProject.kt | 9 +++++++++ .../com/puzzling/puzzlingaos/data/entity/KakaoToken.kt | 8 ++++++++ .../java/com/puzzling/puzzlingaos/data/entity/User.kt | 9 +++++++++ 3 files changed, 26 insertions(+) create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/entity/CurrentProject.kt create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/entity/KakaoToken.kt create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/entity/User.kt diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/entity/CurrentProject.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/entity/CurrentProject.kt new file mode 100644 index 0000000..5152fed --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/entity/CurrentProject.kt @@ -0,0 +1,9 @@ +package com.puzzling.puzzlingaos.data.entity + +import kotlinx.serialization.Serializable + +@Serializable +data class CurrentProject( + val projectId: Int, + val projectName: String, +) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/entity/KakaoToken.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/entity/KakaoToken.kt new file mode 100644 index 0000000..9e05d47 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/entity/KakaoToken.kt @@ -0,0 +1,8 @@ +package com.puzzling.puzzlingaos.data.entity + +import kotlinx.serialization.Serializable + +@Serializable +data class KakaoToken( + val accessToken: String? = null, +) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/entity/User.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/entity/User.kt new file mode 100644 index 0000000..0c6b618 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/entity/User.kt @@ -0,0 +1,9 @@ +package com.puzzling.puzzlingaos.data.entity + +import kotlinx.serialization.Serializable + +@Serializable +data class User( + val memberId: Int, + val name: String, +) \ No newline at end of file From babeea7a6e246e23af49f777f7fdb007420d56fa Mon Sep 17 00:00:00 2001 From: gaeun Date: Sun, 1 Oct 2023 23:50:31 +0900 Subject: [PATCH 05/30] =?UTF-8?q?[DELETE/#100]=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=ED=8C=8C=EC=9D=BC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/puzzling/puzzlingaos/data/entity/KakaoToken.kt | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/entity/KakaoToken.kt diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/entity/KakaoToken.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/entity/KakaoToken.kt deleted file mode 100644 index 9e05d47..0000000 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/entity/KakaoToken.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.puzzling.puzzlingaos.data.entity - -import kotlinx.serialization.Serializable - -@Serializable -data class KakaoToken( - val accessToken: String? = null, -) From 620e005df1aeb5b77886547c66f4193176b66f03 Mon Sep 17 00:00:00 2001 From: gaeun Date: Sun, 1 Oct 2023 23:51:13 +0900 Subject: [PATCH 06/30] =?UTF-8?q?[FEAT/#100]=20Auth=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EB=A0=88=EC=9D=B4=EC=96=B4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/remote/AuthDataSource.kt | 10 ++++++ .../remote/impl/AuthDataSourceImpl.kt | 15 +++++++++ .../data/model/response/ResponseLoginDto.kt | 4 ++- .../data/model/response/ResponseTokenDto.kt | 3 ++ .../data/repository/AuthRepositoryImpl.kt | 32 +++++++++++++++++++ .../puzzlingaos/di/DataSourceModule.kt | 5 +++ .../puzzlingaos/di/RepositoryModule.kt | 4 +++ .../domain/repository/AuthRepository.kt | 10 ++++++ 8 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/datasource/remote/AuthDataSource.kt create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/datasource/remote/impl/AuthDataSourceImpl.kt create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/repository/AuthRepositoryImpl.kt create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/domain/repository/AuthRepository.kt diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/remote/AuthDataSource.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/remote/AuthDataSource.kt new file mode 100644 index 0000000..261f66e --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/remote/AuthDataSource.kt @@ -0,0 +1,10 @@ +package com.puzzling.puzzlingaos.data.datasource.remote + +import com.puzzling.puzzlingaos.data.model.response.ResponseLoginDto +import com.puzzling.puzzlingaos.data.model.response.ResponseTokenDto + +interface AuthDataSource { + suspend fun login(socialPlatform: String): ResponseLoginDto + + suspend fun getToken(): ResponseTokenDto +} 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 new file mode 100644 index 0000000..8fe0d49 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/remote/impl/AuthDataSourceImpl.kt @@ -0,0 +1,15 @@ +package com.puzzling.puzzlingaos.data.datasource.remote.impl + +import com.puzzling.puzzlingaos.data.datasource.remote.AuthDataSource +import com.puzzling.puzzlingaos.data.model.response.ResponseLoginDto +import com.puzzling.puzzlingaos.data.model.response.ResponseTokenDto +import com.puzzling.puzzlingaos.data.service.AuthService +import javax.inject.Inject + +class AuthDataSourceImpl @Inject constructor(private val apiService: AuthService) : AuthDataSource { + override suspend fun login(socialPlatform: String): ResponseLoginDto = + apiService.login(socialPlatform) + + override suspend fun getToken(): ResponseTokenDto = apiService.getToken() + +} \ No newline at end of file diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt index 2d8f520..c7d055f 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt @@ -1,5 +1,6 @@ package com.puzzling.puzzlingaos.data.model.response +import com.puzzling.puzzlingaos.data.entity.Token import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -16,7 +17,6 @@ data class ResponseLoginDto( ) { @Serializable - data class LoginData( @SerialName("name") val name: String, @@ -31,4 +31,6 @@ data class ResponseLoginDto( @SerialName("isNewUser") val isNewUser: Boolean, ) + + fun getToken() = Token(data?.accessToken, data?.refreshToken) } diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseTokenDto.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseTokenDto.kt index d298cda..4f1364f 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseTokenDto.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseTokenDto.kt @@ -1,5 +1,6 @@ package com.puzzling.puzzlingaos.data.model.response +import com.puzzling.puzzlingaos.data.entity.Token import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -20,4 +21,6 @@ data class ResponseTokenDto( val accessToken: String, ) + + fun getToken() = Token(data?.accessToken) } 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 new file mode 100644 index 0000000..83bdfa7 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/repository/AuthRepositoryImpl.kt @@ -0,0 +1,32 @@ +package com.puzzling.puzzlingaos.data.repository + +import android.util.Log +import androidx.datastore.core.DataStore +import com.puzzling.puzzlingaos.data.datasource.remote.AuthDataSource +import com.puzzling.puzzlingaos.data.entity.Token +import com.puzzling.puzzlingaos.domain.repository.AuthRepository +import kotlinx.coroutines.flow.first +import javax.inject.Inject + +class AuthRepositoryImpl @Inject constructor( + private val tokenDataStore: DataStore, + private val authDataSource: AuthDataSource, +) : AuthRepository { + override suspend fun login(socialPlatform: String): Result = runCatching { + authDataSource.login(socialPlatform).getToken() + }.onSuccess { token -> + tokenDataStore.updateData { Token(token.accessToken, token.refreshToken) } + Log.d("AuthRepoImpl", "${tokenDataStore.data.first()}") + }.onFailure { + Log.d("AuthRepoImpl", "$it 에러") + } + + override suspend fun getToken(): Result = runCatching { + authDataSource.getToken().getToken() + }.onSuccess { token -> + tokenDataStore.updateData { Token(token.accessToken, token.refreshToken) } + Log.d("AuthRepoImpl", "${tokenDataStore.data.first()}") + }.onFailure { + Log.d("AuthRepoImpl", "$it 에러") + } +} diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/DataSourceModule.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/DataSourceModule.kt index 2de1142..8cefe8c 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/DataSourceModule.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/DataSourceModule.kt @@ -5,6 +5,7 @@ import com.puzzling.puzzlingaos.data.datasource.remote.MyPageDataSource import com.puzzling.puzzlingaos.data.datasource.remote.ProjectDataSource import com.puzzling.puzzlingaos.data.datasource.remote.TeamDashBoardDataSource import com.puzzling.puzzlingaos.data.datasource.remote.WriteReviewDataSource +import com.puzzling.puzzlingaos.data.datasource.remote.impl.AuthDataSourceImpl import com.puzzling.puzzlingaos.data.datasource.remote.impl.MyDashBoardDataSourceImpl import com.puzzling.puzzlingaos.data.datasource.remote.impl.MyPageDataSourceImpl import com.puzzling.puzzlingaos.data.datasource.remote.impl.ProjectDataSourceImpl @@ -38,4 +39,8 @@ abstract class DataSourceModule { @Singleton @Binds abstract fun providesWriteReviewDataSource(DataSourceImpl: WriteReviewDataSourceImpl): WriteReviewDataSource + + @Singleton + @Binds + abstract fun providesAuthDataSource(DataSourceImpl: AuthDataSourceImpl): AuthDataSourceImpl } diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/RepositoryModule.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/RepositoryModule.kt index 8f0f859..425491b 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/RepositoryModule.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/RepositoryModule.kt @@ -34,4 +34,8 @@ abstract class RepositoryModule { @Singleton @Binds abstract fun providesTokenRepository(repoImpl: TokenRepositoryImpl): TokenRepository + + @Singleton + @Binds + abstract fun providesAuthRepository(repoImpl: AuthRepositoryImpl): AuthRepository } diff --git a/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/AuthRepository.kt b/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/AuthRepository.kt new file mode 100644 index 0000000..5e02ea4 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/AuthRepository.kt @@ -0,0 +1,10 @@ +package com.puzzling.puzzlingaos.domain.repository + +import com.puzzling.puzzlingaos.data.entity.Token + +interface AuthRepository { + + suspend fun login(socialPlatform: String): Result + + suspend fun getToken(): Result +} From 309f45a9bf02efba0c2266f14fac588d4db3fd30 Mon Sep 17 00:00:00 2001 From: gaeun Date: Sun, 1 Oct 2023 23:51:40 +0900 Subject: [PATCH 07/30] =?UTF-8?q?[RENAME/#100]=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=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 --- .../main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt index 22a0c10..cbd9129 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt @@ -21,7 +21,7 @@ object DataStoreModule { @Provides @Singleton - fun providePreferencesDataStore( + fun provideTokenDataStore( @ApplicationContext appContext: Context, tokenDataSource: TokenDataSource, ): DataStore { From f078655067af51de32e56601742b4e2d7ecd80e5 Mon Sep 17 00:00:00 2001 From: gaeun Date: Mon, 2 Oct 2023 00:04:06 +0900 Subject: [PATCH 08/30] =?UTF-8?q?[RENAME/#100]=20api=20DI=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/puzzling/puzzlingaos/di/ApiModule.kt | 6 ++++++ 1 file changed, 6 insertions(+) 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 25a6bc7..044b9d8 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/ApiModule.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/ApiModule.kt @@ -1,5 +1,6 @@ package com.puzzling.puzzlingaos.di +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 @@ -39,4 +40,9 @@ object ApiModule { @Singleton fun provideWriteReviewService(@PuzzlingRetrofit retrofit: Retrofit): WriteReviewService = retrofit.create(WriteReviewService::class.java) + + @Provides + @Singleton + fun provideAuthService(@PuzzlingRetrofit retrofit: Retrofit): AuthService = + retrofit.create(AuthService::class.java) } From d10e5a6caade810c8825caea498b8192413952a9 Mon Sep 17 00:00:00 2001 From: gaeun Date: Mon, 2 Oct 2023 21:30:09 +0900 Subject: [PATCH 09/30] =?UTF-8?q?[FIX/#100]=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/puzzling/puzzlingaos/di/DataSourceModule.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/DataSourceModule.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/DataSourceModule.kt index 8cefe8c..2bf7ca2 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/DataSourceModule.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/DataSourceModule.kt @@ -1,5 +1,6 @@ package com.puzzling.puzzlingaos.di +import com.puzzling.puzzlingaos.data.datasource.remote.AuthDataSource import com.puzzling.puzzlingaos.data.datasource.remote.MyDashBoardDataSource import com.puzzling.puzzlingaos.data.datasource.remote.MyPageDataSource import com.puzzling.puzzlingaos.data.datasource.remote.ProjectDataSource @@ -42,5 +43,5 @@ abstract class DataSourceModule { @Singleton @Binds - abstract fun providesAuthDataSource(DataSourceImpl: AuthDataSourceImpl): AuthDataSourceImpl + abstract fun providesAuthDataSource(DataSourceImpl: AuthDataSourceImpl): AuthDataSource } From ff03ad6902fc6e1416f3e4a147dbe6b7eb943fd2 Mon Sep 17 00:00:00 2001 From: gaeun Date: Mon, 2 Oct 2023 21:31:24 +0900 Subject: [PATCH 10/30] =?UTF-8?q?[FEAT/#100]=20=ED=95=A8=EC=88=98=20DI?= =?UTF-8?q?=EB=A1=9C=20=EC=A3=BC=EC=9E=85=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puzzling/puzzlingaos/di/RetrofitModule.kt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/RetrofitModule.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/RetrofitModule.kt index fefc640..b960014 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/RetrofitModule.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/RetrofitModule.kt @@ -3,13 +3,14 @@ package com.puzzling.puzzlingaos.di import android.util.Log import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import com.puzzling.puzzlingaos.BuildConfig -import com.puzzling.puzzlingaos.BuildConfig.JWT_ACCESS_TOKEN +import com.puzzling.puzzlingaos.domain.repository.TokenRepository import com.puzzling.puzzlingaos.util.isJsonArray import com.puzzling.puzzlingaos.util.isJsonObject import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent +import kotlinx.coroutines.runBlocking import kotlinx.serialization.json.Json import okhttp3.Interceptor import okhttp3.MediaType.Companion.toMediaType @@ -27,10 +28,13 @@ object RetrofitModule { @Provides @Singleton - fun provideOkHttpClient(loggingInterceptor: HttpLoggingInterceptor): OkHttpClient = + fun provideOkHttpClient( + loggingInterceptor: HttpLoggingInterceptor, + tokenInterceptor: Interceptor, + ): OkHttpClient = OkHttpClient.Builder() .addInterceptor(loggingInterceptor) - .addInterceptor(tokenInterceptor()) + .addInterceptor(tokenInterceptor) .build() @Provides @@ -62,13 +66,18 @@ object RetrofitModule { .client(okHttpClient) .build() - private fun tokenInterceptor(): Interceptor { + @Singleton + @Provides + fun tokenInterceptor(tokenRepository: TokenRepository): Interceptor { val requestInterceptor = Interceptor { chain -> val original = chain.request() val builder = original.newBuilder() + val accessToken = runBlocking { + tokenRepository.getToken().accessToken + } builder.addHeader( "Authorization", - JWT_ACCESS_TOKEN, + "Bearer $accessToken", ) chain.proceed(builder.build()) } From 6e77f9af597366e6be6faec8697791deab0c8adb Mon Sep 17 00:00:00 2001 From: gaeun Date: Tue, 3 Oct 2023 23:53:30 +0900 Subject: [PATCH 11/30] =?UTF-8?q?[FIX/#100]=20=EA=B8=B4=20message=EB=8F=84?= =?UTF-8?q?=20=EC=95=94=ED=98=B8=ED=99=94=20=ED=95=A0=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puzzlingaos/data/service/CryptoService.kt | 78 +++++++++++++------ 1 file changed, 54 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/service/CryptoService.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/service/CryptoService.kt index d052fb7..5aec7ef 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/service/CryptoService.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/service/CryptoService.kt @@ -4,6 +4,8 @@ import android.os.Build import android.security.keystore.KeyGenParameterSpec import android.security.keystore.KeyProperties import androidx.annotation.RequiresApi +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream import java.io.InputStream import java.io.OutputStream import java.security.KeyStore @@ -20,18 +22,19 @@ class CryptoService @Inject constructor() { load(null) } - private val encryptCipher = Cipher.getInstance(TRANSFORMATION).apply { - init(Cipher.ENCRYPT_MODE, getKey()) - } + private val encryptCipher + get() = Cipher.getInstance(TRANSFORMATION).apply { + init(Cipher.ENCRYPT_MODE, getKey()) + } - private fun getDecryptCipher(iv: ByteArray): Cipher { + private fun getDecryptCipherForIv(iv: ByteArray): Cipher { return Cipher.getInstance(TRANSFORMATION).apply { init(Cipher.DECRYPT_MODE, getKey(), IvParameterSpec(iv)) } } private fun getKey(): SecretKey { - val existingKey = keyStore.getEntry("secret", null) as? KeyStore.SecretKeyEntry + val existingKey = keyStore.getEntry(ALIAS, null) as? KeyStore.SecretKeyEntry return existingKey?.secretKey ?: createKey() } @@ -39,43 +42,70 @@ class CryptoService @Inject constructor() { return KeyGenerator.getInstance(ALGORITHM).apply { init( KeyGenParameterSpec.Builder( - "secret", + ALIAS, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT, - ).setBlockModes(BLOCK_MODE).setEncryptionPaddings( - PADDING, - ).setUserAuthenticationRequired(false) // 지문인식 같은거 false - .setRandomizedEncryptionRequired(true).build(), + ) + .setKeySize(KEY_SIZE * 8) // key size in bits + .setBlockModes(BLOCK_MODE) + .setEncryptionPaddings(PADDING) + .setUserAuthenticationRequired(false) + .setRandomizedEncryptionRequired(true) + .build(), ) }.generateKey() } - fun encrypt(bytes: ByteArray, outputStream: OutputStream): ByteArray { - val encryptedBytes = encryptCipher.doFinal(bytes) + fun encrypt(bytes: ByteArray, outputStream: OutputStream) { + val cipher = encryptCipher + val iv = cipher.iv outputStream.use { - it.write(encryptCipher.iv.size) - it.write(encryptCipher.iv) - it.write(encryptedBytes.size) - it.write(encryptedBytes) + it.write(iv) + // write the payload in chunks to make sure to support larger data amounts (this would otherwise fail silently and result in corrupted data being read back) + // ////////////////////////////////// + val inputStream = ByteArrayInputStream(bytes) + val buffer = ByteArray(CHUNK_SIZE) + while (inputStream.available() > CHUNK_SIZE) { + inputStream.read(buffer) + val ciphertextChunk = cipher.update(buffer) + it.write(ciphertextChunk) + } + // the last chunk must be written using doFinal() because this takes the padding into account + val remainingBytes = inputStream.readBytes() + val lastChunk = cipher.doFinal(remainingBytes) + it.write(lastChunk) + // //////////////////////////////// } - - return encryptedBytes } fun decrypt(inputStream: InputStream): ByteArray { return inputStream.use { - val ivSize = it.read() - val iv = ByteArray(ivSize) + val iv = ByteArray(KEY_SIZE) it.read(iv) + val cipher = getDecryptCipherForIv(iv) + val outputStream = ByteArrayOutputStream() - val encryptedBytesSize = it.read() - val encryptedBytes = ByteArray(encryptedBytesSize) - it.read(encryptedBytes) + // read the payload in chunks to make sure to support larger data amounts (this would otherwise fail silently and result in corrupted data being read back) + // ////////////////////////////////// + val buffer = ByteArray(CHUNK_SIZE) + while (inputStream.available() > CHUNK_SIZE) { + inputStream.read(buffer) + val ciphertextChunk = cipher.update(buffer) + outputStream.write(ciphertextChunk) + } + // the last chunk must be read using doFinal() because this takes the padding into account + val remainingBytes = inputStream.readBytes() + val lastChunk = cipher.doFinal(remainingBytes) + outputStream.write(lastChunk) + // //////////////////////////////// - getDecryptCipher(iv).doFinal(encryptedBytes) + outputStream.toByteArray() } } companion object { + private const val CHUNK_SIZE = 1024 * 4 // bytes + private const val KEY_SIZE = 16 // bytes + private const val ALIAS = "my_alias" private const val ALGORITHM = KeyProperties.KEY_ALGORITHM_AES private const val BLOCK_MODE = KeyProperties.BLOCK_MODE_CBC private const val PADDING = KeyProperties.ENCRYPTION_PADDING_PKCS7 From 6afa25d0cae123fb05d4f65fb112a89e6baed84e Mon Sep 17 00:00:00 2001 From: gaeun Date: Tue, 3 Oct 2023 23:56:31 +0900 Subject: [PATCH 12/30] =?UTF-8?q?[ADD/#100]=20Dto=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puzzlingaos/data/model/request/RequestLoginDto.kt | 10 ++++++++++ .../data/model/response/ResponseLoginDto.kt | 8 +++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/model/request/RequestLoginDto.kt diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/model/request/RequestLoginDto.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/model/request/RequestLoginDto.kt new file mode 100644 index 0000000..db0b29e --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/model/request/RequestLoginDto.kt @@ -0,0 +1,10 @@ +package com.puzzling.puzzlingaos.data.model.request + +import com.google.gson.annotations.SerializedName +import kotlinx.serialization.Serializable + +@Serializable +data class RequestLoginDto( + @SerializedName("socialPlatform") + val socialPlatform: String, +) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt index c7d055f..97bafe7 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt @@ -7,13 +7,13 @@ import kotlinx.serialization.Serializable @Serializable data class ResponseLoginDto( @SerialName("status") - val status: String, + val status: Int, @SerialName("success") val success: Boolean, @SerialName("message") val message: String, @SerialName("data") - val data: LoginData?, + val data: LoginData, ) { @Serializable @@ -23,7 +23,9 @@ data class ResponseLoginDto( @SerialName("memberId") val memberId: Int, @SerialName("projectId") - val projectId: Int, + val projectId: Int?, + @SerialName("projectName") + val projectName: String?, @SerialName("accessToken") val accessToken: String, @SerialName("refreshToken") From 0abffce4063447dcbd288bdb099eb7602a720d7f Mon Sep 17 00:00:00 2001 From: gaeun Date: Tue, 3 Oct 2023 23:57:52 +0900 Subject: [PATCH 13/30] =?UTF-8?q?[FIX/#100]=20=EC=B6=94=EA=B0=80=ED=95=9C?= =?UTF-8?q?=20Dto=EC=97=90=20=EB=A7=9E=EC=B6=B0=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/remote/impl/AuthDataSourceImpl.kt | 6 +++--- .../com/puzzling/puzzlingaos/data/service/AuthService.kt | 7 ++++--- 2 files changed, 7 insertions(+), 6 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 8fe0d49..5c169bd 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 @@ -1,6 +1,7 @@ package com.puzzling.puzzlingaos.data.datasource.remote.impl import com.puzzling.puzzlingaos.data.datasource.remote.AuthDataSource +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 @@ -8,8 +9,7 @@ import javax.inject.Inject class AuthDataSourceImpl @Inject constructor(private val apiService: AuthService) : AuthDataSource { override suspend fun login(socialPlatform: String): ResponseLoginDto = - apiService.login(socialPlatform) + apiService.login(RequestLoginDto(socialPlatform)) override suspend fun getToken(): ResponseTokenDto = apiService.getToken() - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt index 6dabce3..bf5acd0 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt @@ -1,5 +1,6 @@ package com.puzzling.puzzlingaos.data.service +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 retrofit2.http.Body @@ -7,11 +8,11 @@ import retrofit2.http.GET import retrofit2.http.POST interface AuthService { - @POST("auth") + @POST("api/v1/auth") suspend fun login( - @Body socialPlatform: String, + @Body socialPlatform: RequestLoginDto, ): ResponseLoginDto - @GET("auth/token") + @GET("api/v1/auth/token") suspend fun getToken(): ResponseTokenDto } From c1766953f81e089a9f2252ddd84451fd439868b9 Mon Sep 17 00:00:00 2001 From: gaeun Date: Wed, 4 Oct 2023 13:37:53 +0900 Subject: [PATCH 14/30] =?UTF-8?q?[FEAT/#100]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=20api=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/onboarding/LoginActivity.kt | 5 +++-- .../presentation/onboarding/LoginViewModel.kt | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) 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 bbfd50d..67cae55 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,7 +2,6 @@ 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 @@ -12,6 +11,7 @@ import com.puzzling.puzzlingaos.base.BaseActivity import com.puzzling.puzzlingaos.data.service.KakaoAuthService import com.puzzling.puzzlingaos.databinding.ActivityLoginBinding import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.delay import kotlinx.coroutines.launch import javax.inject.Inject @@ -23,7 +23,6 @@ class LoginActivity : BaseActivity(R.layout.activity_login private val viewModel: LoginViewModel by viewModels() - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) startKakaoLogin() @@ -46,6 +45,8 @@ class LoginActivity : BaseActivity(R.layout.activity_login intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) startActivity(intent) finish() + delay(100) + viewModel.login("KAKAO") } } } 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 6b60acb..717f9a5 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 @@ -5,6 +5,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.kakao.sdk.auth.model.OAuthToken import com.puzzling.puzzlingaos.data.datasource.local.LocalDataSource +import com.puzzling.puzzlingaos.domain.repository.AuthRepository import com.puzzling.puzzlingaos.domain.usecase.onboarding.GetTokenUseCase import com.puzzling.puzzlingaos.domain.usecase.onboarding.PostTokenUseCase import com.puzzling.puzzlingaos.util.KakaoLoginCallback @@ -18,6 +19,7 @@ import javax.inject.Inject class LoginViewModel @Inject constructor( private val postTokenUseCase: PostTokenUseCase, private val getTokenUseCase: GetTokenUseCase, + private val authRepository: AuthRepository, ) : ViewModel() { private val _isKakaoLogin = MutableStateFlow(false) @@ -26,12 +28,17 @@ class LoginViewModel @Inject constructor( val kakaoLoginCallback: (OAuthToken?, Throwable?) -> Unit = { token, error -> KakaoLoginCallback { _isKakaoLogin.value = true - Log.d("LoginViewModel", "토큰!! $token") + Log.d("LoginViewModel", "카카오 로그인 set 토큰 $token") LocalDataSource.setAccessToken("$token") viewModelScope.launch { postTokenUseCase.invoke(it) - Log.d("LoginViewModel", "토큰!! usecase ${getTokenUseCase.invoke()}") + Log.d("LoginViewModel", "카카오 로그인 get 토큰 ${getTokenUseCase.invoke()}") } }.handleResult(token, error) } + + fun login(socialPlatform: String) = viewModelScope.launch { + Log.d("LoginActivity", "로그인 함수 호출") + authRepository.login("KAKAO") + } } From 2997fade69d9f639dab14764d9e4dc85ddedf6ac Mon Sep 17 00:00:00 2001 From: gaeun Date: Wed, 4 Oct 2023 13:38:12 +0900 Subject: [PATCH 15/30] =?UTF-8?q?[FIX/#100]=20=EB=A1=9C=EA=B7=B8=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puzzling/puzzlingaos/data/repository/AuthRepositoryImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 83bdfa7..5a6da72 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 @@ -16,7 +16,7 @@ class AuthRepositoryImpl @Inject constructor( authDataSource.login(socialPlatform).getToken() }.onSuccess { token -> tokenDataStore.updateData { Token(token.accessToken, token.refreshToken) } - Log.d("AuthRepoImpl", "${tokenDataStore.data.first()}") + Log.d("AuthRepoImpl", "AuthRepoImpl get 토큰 ${tokenDataStore.data.first()}") }.onFailure { Log.d("AuthRepoImpl", "$it 에러") } From 0459b425478f7599781e97566d5e0a50b5f46134 Mon Sep 17 00:00:00 2001 From: gaeun Date: Wed, 4 Oct 2023 14:19:58 +0900 Subject: [PATCH 16/30] =?UTF-8?q?[RENAME/#100]=20parameter=20name=20?= =?UTF-8?q?=EB=AA=85=ED=99=95=ED=9E=88=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puzzlingaos/data/repository/TokenRepositoryImpl.kt | 4 ++-- .../puzzling/puzzlingaos/domain/repository/TokenRepository.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/repository/TokenRepositoryImpl.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/repository/TokenRepositoryImpl.kt index e2f9412..d9dc379 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/repository/TokenRepositoryImpl.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/repository/TokenRepositoryImpl.kt @@ -8,8 +8,8 @@ import javax.inject.Inject class TokenRepositoryImpl @Inject constructor(private val dataStore: DataStore) : TokenRepository { - override suspend fun setToken(token: String) { - dataStore.updateData { Token(token) } + override suspend fun setToken(accessToken: String) { + dataStore.updateData { Token(accessToken) } } override suspend fun getToken(): Token = dataStore.data.first() diff --git a/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/TokenRepository.kt b/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/TokenRepository.kt index 93f43ad..ee251fd 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/TokenRepository.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/TokenRepository.kt @@ -3,7 +3,7 @@ package com.puzzling.puzzlingaos.domain.repository import com.puzzling.puzzlingaos.data.entity.Token interface TokenRepository { - suspend fun setToken(token: String) + suspend fun setToken(accessToken: String) suspend fun getToken(): Token } From 751275bcbaa1430792ac83a65a41ed4a92928eae Mon Sep 17 00:00:00 2001 From: gaeun Date: Thu, 5 Oct 2023 23:16:12 +0900 Subject: [PATCH 17/30] =?UTF-8?q?[FEAT/#100]=20data=20class=20=EA=B0=92=20?= =?UTF-8?q?=EC=B4=88=EA=B8=B0=ED=99=94=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/puzzling/puzzlingaos/data/entity/User.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/entity/User.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/entity/User.kt index 0c6b618..e198595 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/entity/User.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/entity/User.kt @@ -4,6 +4,6 @@ import kotlinx.serialization.Serializable @Serializable data class User( - val memberId: Int, - val name: String, -) \ No newline at end of file + val memberId: Int? = null, + val name: String? = null, +) From 21f8d4bec7fbea987aaa5148eb3e391549f212ce Mon Sep 17 00:00:00 2001 From: gaeun Date: Thu, 5 Oct 2023 23:16:32 +0900 Subject: [PATCH 18/30] =?UTF-8?q?[FEAT/#100]=20UserDataSource=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/local/UserDataSource.kt | 38 +++++++++++++++++++ .../puzzlingaos/di/DataStoreModule.kt | 16 ++++++++ 2 files changed, 54 insertions(+) create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/datasource/local/UserDataSource.kt diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/local/UserDataSource.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/local/UserDataSource.kt new file mode 100644 index 0000000..613ce63 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/local/UserDataSource.kt @@ -0,0 +1,38 @@ +package com.puzzling.puzzlingaos.data.datasource.local + +import androidx.datastore.core.Serializer +import com.puzzling.puzzlingaos.data.entity.User +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import kotlinx.serialization.json.Json +import org.apache.commons.lang3.SerializationException +import java.io.InputStream +import java.io.OutputStream + +object UserDataSource : Serializer { + override val defaultValue: User + get() = User() + + override suspend fun readFrom(input: InputStream): User { + return try { + Json.decodeFromString( + deserializer = User.serializer(), + string = input.readBytes().decodeToString(), + ) + } catch (e: SerializationException) { + e.printStackTrace() + defaultValue + } + } + + override suspend fun writeTo(t: User, output: OutputStream) { + withContext(Dispatchers.IO) { + output.write( + Json.encodeToString( + serializer = User.serializer(), + value = t, + ).encodeToByteArray(), + ) + } + } +} diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt index cbd9129..a9fafdf 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt @@ -5,7 +5,9 @@ import androidx.datastore.core.DataStore import androidx.datastore.core.DataStoreFactory import androidx.datastore.dataStoreFile import com.puzzling.puzzlingaos.data.datasource.local.TokenDataSource +import com.puzzling.puzzlingaos.data.datasource.local.UserDataSource import com.puzzling.puzzlingaos.data.entity.Token +import com.puzzling.puzzlingaos.data.entity.User import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -32,4 +34,18 @@ object DataStoreModule { }, ) } + + @Provides + @Singleton + fun provideUserDataStore( + @ApplicationContext appContext: Context, + userDataSource: UserDataSource, + ): DataStore { + return DataStoreFactory.create( + serializer = userDataSource, + produceFile = { + appContext.dataStoreFile(DATA_STORE_FILE_NAME) + }, + ) + } } From dead02eab18b71439aabe5f4790d195ac5eb78a2 Mon Sep 17 00:00:00 2001 From: gaeun Date: Sat, 7 Oct 2023 23:49:05 +0900 Subject: [PATCH 19/30] =?UTF-8?q?[FEAT/#100]=20UserRepo=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/repository/UserRepositoryImpl.kt | 16 ++++++++++++++++ .../puzzling/puzzlingaos/di/RepositoryModule.kt | 4 ++++ .../domain/repository/UserRepository.kt | 9 +++++++++ 3 files changed, 29 insertions(+) create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/repository/UserRepositoryImpl.kt create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/domain/repository/UserRepository.kt diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/repository/UserRepositoryImpl.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/repository/UserRepositoryImpl.kt new file mode 100644 index 0000000..da5813f --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/repository/UserRepositoryImpl.kt @@ -0,0 +1,16 @@ +package com.puzzling.puzzlingaos.data.repository + +import androidx.datastore.core.DataStore +import com.puzzling.puzzlingaos.data.entity.User +import com.puzzling.puzzlingaos.domain.repository.UserRepository +import kotlinx.coroutines.flow.first +import javax.inject.Inject + +class UserRepositoryImpl @Inject constructor(private val dataStore: DataStore) : + UserRepository { + override suspend fun setUserInfo(userInfo: User) { + dataStore.updateData { User(userInfo.memberId, userInfo.name) } + } + + override suspend fun getUserInfo(): User = dataStore.data.first() +} diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/RepositoryModule.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/RepositoryModule.kt index 425491b..36f8f3b 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/RepositoryModule.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/RepositoryModule.kt @@ -38,4 +38,8 @@ abstract class RepositoryModule { @Singleton @Binds abstract fun providesAuthRepository(repoImpl: AuthRepositoryImpl): AuthRepository + + @Singleton + @Binds + abstract fun providesUserRepository(repoImpl: UserRepositoryImpl): UserRepository } diff --git a/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/UserRepository.kt b/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/UserRepository.kt new file mode 100644 index 0000000..aaf24b4 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/UserRepository.kt @@ -0,0 +1,9 @@ +package com.puzzling.puzzlingaos.domain.repository + +import com.puzzling.puzzlingaos.data.entity.User + +interface UserRepository { + + suspend fun setUserInfo(userInfo: User) + suspend fun getUserInfo(): User +} From 8b45a79ec6b37b91a5ff81b7a1205e9c1d516c63 Mon Sep 17 00:00:00 2001 From: gaeun Date: Sun, 8 Oct 2023 23:39:37 +0900 Subject: [PATCH 20/30] =?UTF-8?q?[RENAME/#40]=20useCase=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puzzlingaos/domain/usecase/onboarding/GetTokenUseCase.kt | 4 ++-- .../puzzlingaos/domain/usecase/onboarding/PostTokenUseCase.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetTokenUseCase.kt b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetTokenUseCase.kt index 3687519..9549a2a 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetTokenUseCase.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetTokenUseCase.kt @@ -6,8 +6,8 @@ import javax.inject.Singleton @Singleton class GetTokenUseCase @Inject constructor( - private val tokenRepository: TokenRepository, + private val repository: TokenRepository, ) { - suspend operator fun invoke() = tokenRepository.getToken() + suspend operator fun invoke() = repository.getToken() } diff --git a/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/PostTokenUseCase.kt b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/PostTokenUseCase.kt index dcf39d5..3954a3a 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/PostTokenUseCase.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/PostTokenUseCase.kt @@ -5,6 +5,6 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class PostTokenUseCase @Inject constructor(private val tokenRepository: TokenRepository) { - suspend operator fun invoke(token: String) = tokenRepository.setToken(token) +class PostTokenUseCase @Inject constructor(private val repository: TokenRepository) { + suspend operator fun invoke(token: String) = repository.setToken(token) } From 545f99dd10bcc3083be65b62cf2fa90055af3850 Mon Sep 17 00:00:00 2001 From: gaeun Date: Mon, 9 Oct 2023 00:30:19 +0900 Subject: [PATCH 21/30] =?UTF-8?q?[FIX/#100]=20UserDataStore=20object=20->?= =?UTF-8?q?=20class=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puzzlingaos/data/datasource/local/UserDataSource.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/local/UserDataSource.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/local/UserDataSource.kt index 613ce63..d8b74ab 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/local/UserDataSource.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/datasource/local/UserDataSource.kt @@ -8,8 +8,9 @@ import kotlinx.serialization.json.Json import org.apache.commons.lang3.SerializationException import java.io.InputStream import java.io.OutputStream +import javax.inject.Inject -object UserDataSource : Serializer { +class UserDataSource @Inject constructor() : Serializer { override val defaultValue: User get() = User() From eb4eb0c836657b3f26f746c25451743af0b69be6 Mon Sep 17 00:00:00 2001 From: gaeun Date: Mon, 9 Oct 2023 00:31:19 +0900 Subject: [PATCH 22/30] =?UTF-8?q?[DELETE/#100]=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=ED=95=A8=EC=88=98=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puzzlingaos/data/model/response/ResponseLoginDto.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt index 97bafe7..f24fe24 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/model/response/ResponseLoginDto.kt @@ -1,6 +1,5 @@ package com.puzzling.puzzlingaos.data.model.response -import com.puzzling.puzzlingaos.data.entity.Token import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -33,6 +32,4 @@ data class ResponseLoginDto( @SerialName("isNewUser") val isNewUser: Boolean, ) - - fun getToken() = Token(data?.accessToken, data?.refreshToken) } From 09d9b517ded51b2769a74cdbc4a9ef45708f2f00 Mon Sep 17 00:00:00 2001 From: gaeun Date: Tue, 10 Oct 2023 23:50:14 +0900 Subject: [PATCH 23/30] =?UTF-8?q?[FIX/#100]=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=EC=A0=80=EC=9E=A5=20=ED=8C=8C=EC=9D=BC=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/puzzling/puzzlingaos/di/DataStoreModule.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt index a9fafdf..41b7fed 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/DataStoreModule.kt @@ -18,8 +18,8 @@ import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) object DataStoreModule { - private const val USER_PREFERENCES_NAME = "user_preferences" - private const val DATA_STORE_FILE_NAME = "user_prefs.pb" + private const val USER_DATA_STORE_FILE_NAME = "user_prefs.pb" + private const val TOKEN_DATA_STORE_FILE_NAME = "token_prefs.pb" @Provides @Singleton @@ -30,7 +30,7 @@ object DataStoreModule { return DataStoreFactory.create( serializer = tokenDataSource, produceFile = { - appContext.dataStoreFile(DATA_STORE_FILE_NAME) + appContext.dataStoreFile(TOKEN_DATA_STORE_FILE_NAME) }, ) } @@ -44,7 +44,7 @@ object DataStoreModule { return DataStoreFactory.create( serializer = userDataSource, produceFile = { - appContext.dataStoreFile(DATA_STORE_FILE_NAME) + appContext.dataStoreFile(USER_DATA_STORE_FILE_NAME) }, ) } From e598b9b346d8b48e992bc5a9302682c46c933b2a Mon Sep 17 00:00:00 2001 From: gaeun Date: Tue, 10 Oct 2023 23:50:49 +0900 Subject: [PATCH 24/30] =?UTF-8?q?[FEAT/#100]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=EC=8B=9C=20=EC=9C=A0=EC=A0=80=20=EC=A0=95=EB=B3=B4=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/repository/AuthRepositoryImpl.kt | 16 +++++++++++----- .../domain/repository/AuthRepository.kt | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) 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 5a6da72..879480f 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,21 +2,27 @@ 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 +import com.puzzling.puzzlingaos.data.model.response.ResponseLoginDto import com.puzzling.puzzlingaos.domain.repository.AuthRepository import kotlinx.coroutines.flow.first import javax.inject.Inject class AuthRepositoryImpl @Inject constructor( private val tokenDataStore: DataStore, + private val userDataSource: DataStore, private val authDataSource: AuthDataSource, ) : AuthRepository { - override suspend fun login(socialPlatform: String): Result = runCatching { - authDataSource.login(socialPlatform).getToken() - }.onSuccess { token -> - tokenDataStore.updateData { Token(token.accessToken, token.refreshToken) } - Log.d("AuthRepoImpl", "AuthRepoImpl get 토큰 ${tokenDataStore.data.first()}") + override suspend fun login(socialPlatform: String): Result = runCatching { + authDataSource.login(socialPlatform) + }.onSuccess { result -> + tokenDataStore.updateData { Token(result.data.accessToken, result.data.refreshToken) } + userDataSource.updateData { User(result.data.memberId, result.data.name) } + Log.d("AuthRepoImpl", "$result") + Log.d("AuthRepoImpl", "AuthRepoImpl get 토큰 ${userDataSource.data.first()}") }.onFailure { Log.d("AuthRepoImpl", "$it 에러") } diff --git a/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/AuthRepository.kt b/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/AuthRepository.kt index 5e02ea4..652124a 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/AuthRepository.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/domain/repository/AuthRepository.kt @@ -1,10 +1,11 @@ package com.puzzling.puzzlingaos.domain.repository import com.puzzling.puzzlingaos.data.entity.Token +import com.puzzling.puzzlingaos.data.model.response.ResponseLoginDto interface AuthRepository { - suspend fun login(socialPlatform: String): Result + suspend fun login(socialPlatform: String): Result suspend fun getToken(): Result } From ace4691e100258602daf483a9119697492b06a6a Mon Sep 17 00:00:00 2001 From: gaeun Date: Wed, 11 Oct 2023 00:10:47 +0900 Subject: [PATCH 25/30] =?UTF-8?q?[FEAT/#100]=20userInfo=20=EC=97=AC?= =?UTF-8?q?=EB=B6=80=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=9E=90=EB=8F=99=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/usecase/onboarding/GetUserUseCase.kt | 11 +++++++++++ .../presentation/onboarding/LoginActivity.kt | 14 ++++++++++++++ .../presentation/onboarding/LoginViewModel.kt | 13 +++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetUserUseCase.kt diff --git a/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetUserUseCase.kt b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetUserUseCase.kt new file mode 100644 index 0000000..f462767 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetUserUseCase.kt @@ -0,0 +1,11 @@ +package com.puzzling.puzzlingaos.domain.usecase.onboarding + +import com.puzzling.puzzlingaos.domain.repository.UserRepository +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class GetUserUseCase @Inject constructor(private val repository: UserRepository) { + + suspend operator fun invoke() = repository.getUserInfo() +} 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 67cae55..150d6a3 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 @@ -25,10 +25,24 @@ class LoginActivity : BaseActivity(R.layout.activity_login override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + isAlreadyLogin() startKakaoLogin() isKakaoLoginSuccess() } + private fun isAlreadyLogin() { + viewModel.checkIsAlreadyLogin() + viewModel.isAlreadyLogin.observe(this) { isAlreadyLogin -> + if (isAlreadyLogin) { + val intent = + Intent(this@LoginActivity, ChooseJoinRegisterActivity::class.java) + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) + startActivity(intent) + finish() + } + } + } + private fun startKakaoLogin() { binding.ibLoginKakao.setOnClickListener { kakakoAuthService.startKakaoLogin(viewModel.kakaoLoginCallback) 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 717f9a5..2a31be4 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 @@ -1,12 +1,15 @@ package com.puzzling.puzzlingaos.presentation.onboarding import android.util.Log +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.kakao.sdk.auth.model.OAuthToken import com.puzzling.puzzlingaos.data.datasource.local.LocalDataSource import com.puzzling.puzzlingaos.domain.repository.AuthRepository import com.puzzling.puzzlingaos.domain.usecase.onboarding.GetTokenUseCase +import com.puzzling.puzzlingaos.domain.usecase.onboarding.GetUserUseCase import com.puzzling.puzzlingaos.domain.usecase.onboarding.PostTokenUseCase import com.puzzling.puzzlingaos.util.KakaoLoginCallback import dagger.hilt.android.lifecycle.HiltViewModel @@ -19,12 +22,16 @@ import javax.inject.Inject class LoginViewModel @Inject constructor( private val postTokenUseCase: PostTokenUseCase, private val getTokenUseCase: GetTokenUseCase, + private val getUserUseCase: GetUserUseCase, private val authRepository: AuthRepository, ) : ViewModel() { private val _isKakaoLogin = MutableStateFlow(false) val isKakaoLogin = _isKakaoLogin.asStateFlow() + private val _isAlreadyLogin = MutableLiveData() + val isAlreadyLogin: LiveData get() = _isAlreadyLogin + val kakaoLoginCallback: (OAuthToken?, Throwable?) -> Unit = { token, error -> KakaoLoginCallback { _isKakaoLogin.value = true @@ -41,4 +48,10 @@ class LoginViewModel @Inject constructor( Log.d("LoginActivity", "로그인 함수 호출") authRepository.login("KAKAO") } + + fun checkIsAlreadyLogin() = viewModelScope.launch { + var userInfo = getUserUseCase.invoke() + _isAlreadyLogin.value = !userInfo.name.isNullOrBlank() + Log.d("userInfo", "$userInfo") + } } From b65dc6d55b1c68be6acf5dfc00af98765eb8fb54 Mon Sep 17 00:00:00 2001 From: gaeun Date: Thu, 12 Oct 2023 22:47:44 +0900 Subject: [PATCH 26/30] =?UTF-8?q?[FEAT/#100]=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EC=9E=AC=EB=B0=9C=EA=B8=89=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...okenUseCase.kt => GetLocalTokenUseCase.kt} | 2 +- .../onboarding/GetRemoteTokenUseCase.kt | 9 ++++++++ ...kenUseCase.kt => PostLocalTokenUseCase.kt} | 2 +- .../presentation/onboarding/LoginViewModel.kt | 22 ++++++++++++++----- 4 files changed, 27 insertions(+), 8 deletions(-) rename app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/{GetTokenUseCase.kt => GetLocalTokenUseCase.kt} (86%) create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetRemoteTokenUseCase.kt rename app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/{PostTokenUseCase.kt => PostLocalTokenUseCase.kt} (75%) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetTokenUseCase.kt b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetLocalTokenUseCase.kt similarity index 86% rename from app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetTokenUseCase.kt rename to app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetLocalTokenUseCase.kt index 9549a2a..2dc6b46 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetTokenUseCase.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetLocalTokenUseCase.kt @@ -5,7 +5,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class GetTokenUseCase @Inject constructor( +class GetLocalTokenUseCase @Inject constructor( private val repository: TokenRepository, ) { diff --git a/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetRemoteTokenUseCase.kt b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetRemoteTokenUseCase.kt new file mode 100644 index 0000000..3e2b1e0 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/GetRemoteTokenUseCase.kt @@ -0,0 +1,9 @@ +package com.puzzling.puzzlingaos.domain.usecase.onboarding + +import com.puzzling.puzzlingaos.domain.repository.AuthRepository +import javax.inject.Inject + +class GetRemoteTokenUseCase @Inject constructor(private val repository: AuthRepository) { + + suspend operator fun invoke() = repository.getToken() +} diff --git a/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/PostTokenUseCase.kt b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/PostLocalTokenUseCase.kt similarity index 75% rename from app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/PostTokenUseCase.kt rename to app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/PostLocalTokenUseCase.kt index 3954a3a..a839458 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/PostTokenUseCase.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/domain/usecase/onboarding/PostLocalTokenUseCase.kt @@ -5,6 +5,6 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class PostTokenUseCase @Inject constructor(private val repository: TokenRepository) { +class PostLocalTokenUseCase @Inject constructor(private val repository: TokenRepository) { suspend operator fun invoke(token: String) = repository.setToken(token) } 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 2a31be4..c29450b 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 @@ -8,9 +8,10 @@ import androidx.lifecycle.viewModelScope import com.kakao.sdk.auth.model.OAuthToken import com.puzzling.puzzlingaos.data.datasource.local.LocalDataSource import com.puzzling.puzzlingaos.domain.repository.AuthRepository -import com.puzzling.puzzlingaos.domain.usecase.onboarding.GetTokenUseCase +import com.puzzling.puzzlingaos.domain.usecase.onboarding.GetLocalTokenUseCase +import com.puzzling.puzzlingaos.domain.usecase.onboarding.GetRemoteTokenUseCase import com.puzzling.puzzlingaos.domain.usecase.onboarding.GetUserUseCase -import com.puzzling.puzzlingaos.domain.usecase.onboarding.PostTokenUseCase +import com.puzzling.puzzlingaos.domain.usecase.onboarding.PostLocalTokenUseCase import com.puzzling.puzzlingaos.util.KakaoLoginCallback import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow @@ -20,9 +21,10 @@ import javax.inject.Inject @HiltViewModel class LoginViewModel @Inject constructor( - private val postTokenUseCase: PostTokenUseCase, - private val getTokenUseCase: GetTokenUseCase, + private val postLocalTokenUseCase: PostLocalTokenUseCase, + private val getLocalTokenUseCase: GetLocalTokenUseCase, private val getUserUseCase: GetUserUseCase, + private val getRemoteTokenUseCase: GetRemoteTokenUseCase, private val authRepository: AuthRepository, ) : ViewModel() { @@ -38,12 +40,16 @@ class LoginViewModel @Inject constructor( Log.d("LoginViewModel", "카카오 로그인 set 토큰 $token") LocalDataSource.setAccessToken("$token") viewModelScope.launch { - postTokenUseCase.invoke(it) - Log.d("LoginViewModel", "카카오 로그인 get 토큰 ${getTokenUseCase.invoke()}") + postLocalTokenUseCase.invoke(it) + Log.d("LoginViewModel", "카카오 로그인 get 토큰 ${getLocalTokenUseCase.invoke()}") } }.handleResult(token, error) } + init { + getToken() + } + fun login(socialPlatform: String) = viewModelScope.launch { Log.d("LoginActivity", "로그인 함수 호출") authRepository.login("KAKAO") @@ -54,4 +60,8 @@ class LoginViewModel @Inject constructor( _isAlreadyLogin.value = !userInfo.name.isNullOrBlank() Log.d("userInfo", "$userInfo") } + + fun getToken() = viewModelScope.launch { + getRemoteTokenUseCase.invoke() + } } From 0f6344a8a9e4b70f4f02feef9be148ba7c54913a Mon Sep 17 00:00:00 2001 From: gaeun Date: Fri, 13 Oct 2023 20:24:02 +0900 Subject: [PATCH 27/30] =?UTF-8?q?[ADD/#100]=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EC=9E=AC=EB=B0=9C=EA=B8=89=20interceptor=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20annotation=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/puzzling/puzzlingaos/di/Qualifier.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/Qualifier.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/Qualifier.kt index 6d3e0db..d6ece9d 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/Qualifier.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/Qualifier.kt @@ -5,3 +5,7 @@ import javax.inject.Qualifier @Qualifier @Retention(AnnotationRetention.BINARY) annotation class PuzzlingRetrofit + +@Qualifier +@Retention(AnnotationRetention.BINARY) +annotation class ReIssueRetrofit \ No newline at end of file From 41e8a1feb7763c2b0943dc4e457d82b1fb5d1910 Mon Sep 17 00:00:00 2001 From: gaeun Date: Sat, 14 Oct 2023 13:58:25 +0900 Subject: [PATCH 28/30] =?UTF-8?q?[FIX/#100]=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EC=9E=AC=EB=B0=9C=EA=B8=89=EC=9D=84=20=EC=9C=84=ED=95=9C=20ser?= =?UTF-8?q?vice=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/puzzling/puzzlingaos/data/service/AuthService.kt | 5 ----- .../puzzlingaos/data/service/ReIssueTokenService.kt | 9 +++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/data/service/ReIssueTokenService.kt diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt index bf5acd0..fa6af28 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/service/AuthService.kt @@ -2,9 +2,7 @@ package com.puzzling.puzzlingaos.data.service 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 retrofit2.http.Body -import retrofit2.http.GET import retrofit2.http.POST interface AuthService { @@ -12,7 +10,4 @@ interface AuthService { suspend fun login( @Body socialPlatform: RequestLoginDto, ): ResponseLoginDto - - @GET("api/v1/auth/token") - suspend fun getToken(): ResponseTokenDto } diff --git a/app/src/main/java/com/puzzling/puzzlingaos/data/service/ReIssueTokenService.kt b/app/src/main/java/com/puzzling/puzzlingaos/data/service/ReIssueTokenService.kt new file mode 100644 index 0000000..b5b12e4 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/data/service/ReIssueTokenService.kt @@ -0,0 +1,9 @@ +package com.puzzling.puzzlingaos.data.service + +import com.puzzling.puzzlingaos.data.model.response.ResponseTokenDto +import retrofit2.http.GET + +interface ReIssueTokenService { + @GET("api/v1/auth/token") + suspend fun getToken(): ResponseTokenDto +} From 4a18115b7a68fe0cda0ae455facd75231fb7db18 Mon Sep 17 00:00:00 2001 From: gaeun Date: Sat, 14 Oct 2023 13:59:36 +0900 Subject: [PATCH 29/30] =?UTF-8?q?[ADD/#100]=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EC=9E=AC=EB=B0=9C=EA=B8=89=20Retrofit=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puzzlingaos/di/ReIssueRetrofitModule.kt | 69 +++++++++++++++++++ .../puzzling/puzzlingaos/di/RetrofitModule.kt | 16 +++-- 2 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/com/puzzling/puzzlingaos/di/ReIssueRetrofitModule.kt diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/ReIssueRetrofitModule.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/ReIssueRetrofitModule.kt new file mode 100644 index 0000000..8a8e532 --- /dev/null +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/ReIssueRetrofitModule.kt @@ -0,0 +1,69 @@ +package com.puzzling.puzzlingaos.di + +import android.util.Log +import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory +import com.puzzling.puzzlingaos.BuildConfig +import com.puzzling.puzzlingaos.domain.repository.TokenRepository +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import kotlinx.coroutines.runBlocking +import kotlinx.serialization.json.Json +import okhttp3.Interceptor +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Retrofit +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object ReIssueRetrofitModule { + private const val PUZZLING_BASE_URL = BuildConfig.PUZZLING_BASE_URL + + @Provides + @Singleton + @ReIssueRetrofit + fun provideReIssueOkHttpClient( + loggingInterceptor: HttpLoggingInterceptor, + @ReIssueRetrofit tokenInterceptor: Interceptor, + ): OkHttpClient = + OkHttpClient.Builder() + .addInterceptor(loggingInterceptor) + .addInterceptor(tokenInterceptor) + .build() + + @Singleton + @Provides + @ReIssueRetrofit + fun provideReIssueTokenRetrofit(@ReIssueRetrofit okHttpClient: OkHttpClient): Retrofit = + Retrofit.Builder() + .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) + .baseUrl(PUZZLING_BASE_URL) + .client(okHttpClient) + .build() + + @Singleton + @Provides + @ReIssueRetrofit + fun reIssueTokenInterceptor(tokenRepository: TokenRepository): Interceptor { + val requestInterceptor = Interceptor { chain -> + val original = chain.request() + val builder = original.newBuilder() + val token = runBlocking { + tokenRepository.getToken() + } + Log.d("ReIssueRetrofitModule", "토큰 $token") + builder.addHeader( + "Authorization", + "Bearer ${token.accessToken}", + ).addHeader( + "Refresh", + "Bearer ${token.refreshToken}", + ) + chain.proceed(builder.build()) + } + return requestInterceptor + } +} diff --git a/app/src/main/java/com/puzzling/puzzlingaos/di/RetrofitModule.kt b/app/src/main/java/com/puzzling/puzzlingaos/di/RetrofitModule.kt index b960014..5c64e31 100644 --- a/app/src/main/java/com/puzzling/puzzlingaos/di/RetrofitModule.kt +++ b/app/src/main/java/com/puzzling/puzzlingaos/di/RetrofitModule.kt @@ -28,9 +28,10 @@ object RetrofitModule { @Provides @Singleton + @PuzzlingRetrofit fun provideOkHttpClient( loggingInterceptor: HttpLoggingInterceptor, - tokenInterceptor: Interceptor, + @PuzzlingRetrofit tokenInterceptor: Interceptor, ): OkHttpClient = OkHttpClient.Builder() .addInterceptor(loggingInterceptor) @@ -60,14 +61,16 @@ object RetrofitModule { @Singleton @Provides @PuzzlingRetrofit - fun providePuzzlingRetrofit(okHttpClient: OkHttpClient): Retrofit = Retrofit.Builder() - .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) - .baseUrl(PUZZLING_BASE_URL) - .client(okHttpClient) - .build() + fun providePuzzlingRetrofit(@PuzzlingRetrofit okHttpClient: OkHttpClient): Retrofit = + Retrofit.Builder() + .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) + .baseUrl(PUZZLING_BASE_URL) + .client(okHttpClient) + .build() @Singleton @Provides + @PuzzlingRetrofit fun tokenInterceptor(tokenRepository: TokenRepository): Interceptor { val requestInterceptor = Interceptor { chain -> val original = chain.request() @@ -75,6 +78,7 @@ object RetrofitModule { val accessToken = runBlocking { tokenRepository.getToken().accessToken } + Log.d("RetrofitModule", "토큰 $accessToken") builder.addHeader( "Authorization", "Bearer $accessToken", From 651e6bb9d54f34b9d809a8ba42e61d1fcbf47d7b Mon Sep 17 00:00:00 2001 From: gaeun Date: Sun, 15 Oct 2023 14:00:33 +0900 Subject: [PATCH 30/30] =?UTF-8?q?[FEAT/#100]=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EC=9E=AC=EB=B0=9C=EA=B8=89=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=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")