Skip to content

Commit

Permalink
#219 사용자 상세 정보(CognitoUserDetails) 로드 테스트 성공
Browse files Browse the repository at this point in the history
  • Loading branch information
pknujsp committed Mar 11, 2024
1 parent ad97ca5 commit cb5c9e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import com.android.mediproject.core.network.datasource.sign.LoginRequest
import com.android.mediproject.core.network.datasource.sign.SignUpRequest
import com.android.mediproject.core.network.datasource.sign.SignupDataSource

private const val USER_NAME = "custom:user_name"

internal class SignRepositoryImpl(
private val loginDataSource: LoginDataSource,
private val signupDataSource: SignupDataSource,
Expand All @@ -26,7 +28,7 @@ internal class SignRepositoryImpl(
).fold(
onSuccess = {
accountSessionRepository.updateSession(it.userSession)
accountSessionRepository.updateAccount(loginParameter.email, it.userSession.username)
accountSessionRepository.updateAccount(loginParameter.email, it.attr.attributes.attributes[USER_NAME]!!)
appDataStore.saveSkipIntro(true)
LoginState.Success
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ class LoginDataSourceImpl(
) : LoginDataSource {

override suspend fun login(request: LoginRequest): Result<LoginResponse> {
val session = getSession(request)
session.fold(
return getSession(request).fold(
onSuccess = { userSession ->
val attr = getUserAttr(userSession)
return attr.fold(
getUserAttr(userSession).fold(
onSuccess = { userAttr ->
Result.success(LoginResponse(userSession, userAttr))
},
onFailure = { Result.failure(it) },
)
},
onFailure = { return Result.failure(it) },
onFailure = { Result.failure(it) },
)
}

Expand Down Expand Up @@ -72,7 +70,7 @@ class LoginDataSourceImpl(
}

private suspend fun getUserAttr(session: CognitoUserSession) = suspendCoroutine<Result<CognitoUserDetails>> {
userPool.getUser(session.username).getDetails(
userPool.currentUser.getDetails(
object : GetDetailsHandler {
override fun onSuccess(cognitoUserDetails: CognitoUserDetails) {
it.resume(Result.success(cognitoUserDetails))
Expand Down

0 comments on commit cb5c9e7

Please sign in to comment.