Skip to content

Commit

Permalink
[FEATURE] #15 : 사용자 회원가입 유스케이스 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongjaino committed Oct 10, 2023
1 parent 734a5ab commit 53bc9a9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.wap.wapp.core.domain.usecase.auth

import com.wap.wapp.core.data.repository.auth.AuthRepository
import com.wap.wapp.core.data.repository.user.UserRepository
import com.wap.wapp.core.domain.model.AuthState
import com.wap.wapp.core.domain.model.AuthState.SIGN_IN
import com.wap.wapp.core.domain.model.AuthState.SIGN_UP
import dagger.hilt.android.scopes.ActivityScoped
import javax.inject.Inject

@ActivityScoped
class SignInUseCase @Inject constructor(
private val authRepository: AuthRepository,
private val userRepository: UserRepository,
) {
suspend operator fun invoke(email: String): Result<AuthState> {
return runCatching {
val userId = authRepository.signIn(email)
.getOrThrow()

userRepository.getUserProfile(userId)
.onFailure { exception ->
// 만약 사용자를 찾을 수 없는 경우, 회원가입
val userNotFoundException = IllegalStateException()
if (exception == userNotFoundException) {
return Result.success(SIGN_UP)
}
}
// 사용자를 찾은 경우, 로그인
SIGN_IN
}
}
}

0 comments on commit 53bc9a9

Please sign in to comment.