Skip to content

Commit

Permalink
[feat/#122] V2 로그인 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
SsongSik committed Aug 27, 2024
1 parent 88ed452 commit 8b1e59d
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 4 deletions.
Binary file modified buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin
Binary file not shown.
Binary file not shown.
Binary file modified buildSrc/build/libs/buildSrc.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ interface SignupRemoteDataSource {
accessToken: String,
): ResponsePostSignupDto

suspend fun getSignupV2(
snsProvider: String,
accessToken: String,
): ResponsePostSignupDto

suspend fun deleteWithdraw(): Unit
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ class SignupRemoteDataSourceImpl @Inject constructor(
return signupService.getSignupMember(accessToken)
}

override suspend fun getSignupV2(
snsProvider: String,
accessToken: String
): ResponsePostSignupDto {
return signupService.getSignupMemberV2(snsProvider, accessToken)
}

override suspend fun deleteWithdraw(): Unit {
return signupService.deleteSignupMember()
}
Expand Down
6 changes: 6 additions & 0 deletions data/src/main/java/com/dpm/data/remote/SignupService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ interface SignupService {
@Path("accessToken") accessToken: String,
): ResponsePostSignupDto

@GET("/api/v2/members/{snsProvider}/{token}")
suspend fun getSignupMemberV2(
@Path("snsProvider") snsProvider: String,
@Path("token") accessToken: String,
): ResponsePostSignupDto

@DELETE("/api/v1/members")
suspend fun deleteSignupMember()
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ class SignupRepositoryImpl @Inject constructor(
}
}

override suspend fun getSignupV2(
snsProvider: String,
accessToken: String
): Result<SignupTokenModel> {
return runCatching {
signupRemoteDataSource.getSignupV2(snsProvider, accessToken).toSignupTokenModel()
}
}

override suspend fun deleteWithdraw(): Result<Unit> {
return runCatching {
signupRemoteDataSource.deleteWithdraw()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ interface SignupRepository {
accessToken: String
): Result<SignupTokenModel>

suspend fun getSignupV2(
snsProvider: String,
accessToken: String
): Result<SignupTokenModel>

suspend fun deleteWithdraw(): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ class KakaoSignupActivity : BaseActivity<FragmentKakaoSignupBinding>({
val userName = account.givenName
val serverAuth = account.serverAuthCode
account.idToken
Intent(this, NicknameInputActivity::class.java).apply {
putExtra("kakaoToken", account.idToken)
startActivity(this)
}

signUpViewModel.updateGoogleToken(account.serverAuthCode.orEmpty())

// Intent(this, NicknameInputActivity::class.java).apply {
// putExtra("kakaoToken", account.idToken)
// startActivity(this)
// }

} catch (e: ApiException) {
Timber.e(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,21 @@ class KakaoSignupViewModel @Inject constructor(
}
}

fun updateGoogleToken(token: String) {
viewModelScope.launch {
_loginUiState.emit(LoginUiState.Loading)
signupRepository.getSignupV2("GOOGLE", token)
.onSuccess {
if (it.jwtToken.isEmpty()) {
_kakaoToken.value = token
} else {
sharedPreference.token = it.jwtToken
_loginUiState.emit(LoginUiState.LoginSuccess)
}
}.onFailure {
_kakaoToken.value = token
}
}
}

}

0 comments on commit 8b1e59d

Please sign in to comment.