-
Notifications
You must be signed in to change notification settings - Fork 1
✨[FEAT]: 버블 계정 관리 #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
✨[FEAT]: 버블 계정 관리 #136
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import com.umc.edison.data.token.TokenManager | |
| import com.umc.edison.domain.DataResource | ||
| import com.umc.edison.domain.model.identity.Identity | ||
| import com.umc.edison.domain.model.user.User | ||
| import com.umc.edison.domain.repository.BubbleRepository | ||
| import com.umc.edison.domain.repository.UserRepository | ||
| import kotlinx.coroutines.flow.Flow | ||
| import javax.inject.Inject | ||
|
|
@@ -17,12 +18,16 @@ class UserRepositoryImpl @Inject constructor( | |
| private val userRemoteDataSource: UserRemoteDataSource, | ||
| private val resourceFactory: FlowBoundResourceFactory, | ||
| private val tokenManager: TokenManager, | ||
| private val bubbleRepository: BubbleRepository | ||
| ) : UserRepository { | ||
| // CREATE | ||
|
|
||
| override fun googleLogin(idToken: String): Flow<DataResource<User>> = resourceFactory.remote( | ||
| dataAction = { | ||
| val userWithToken: UserWithTokenEntity = userRemoteDataSource.googleLogin(idToken) | ||
| val userEmail = userWithToken.user.email | ||
| tokenManager.setToken(userWithToken.accessToken, userWithToken.refreshToken) | ||
| tokenManager.saveUserId(userEmail) | ||
| bubbleRepository.linkGuestBubblesToUser(userEmail) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 로컬 DB에 저장되는 userId가 email의 의미라면 userId 보다는 email 필드로 추가되는 것이 적절해보여요!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추가로 로그인/회원가입 API 성공 후에 대한 처리는 비즈니스 시나리오에 가깝기 때문에 Repository보다 UseCase에 두는 건 어떨까요?
이렇게 하면 API 성공 후 처리가 비즈니스 로직으로 UseCase에 모이고, Repository는 데이터 접근만 담당하게될 수 있을 거 같아요. 토큰 저장의 역할도 repository가 할지 UseCase에서 할지 생각해보면 좋을 거 같네요! |
||
| userWithToken | ||
| } | ||
| ) | ||
|
|
@@ -39,17 +44,19 @@ class UserRepositoryImpl @Inject constructor( | |
| nickname = nickname, | ||
| identity = identity.map { it.toData() } | ||
| ) | ||
| val userEmail = userWithToken.user.email | ||
| tokenManager.setToken(userWithToken.accessToken, userWithToken.refreshToken) | ||
| tokenManager.saveUserId(userEmail) | ||
| bubbleRepository.linkGuestBubblesToUser(userEmail) | ||
|
|
||
| userWithToken | ||
| } | ||
| ) | ||
|
|
||
|
|
||
|
|
||
| // READ | ||
| override fun getLogInState(): Flow<DataResource<Boolean>> = resourceFactory.local( | ||
| dataAction = { | ||
| tokenManager.loadAccessToken()?.isNotEmpty() | ||
| tokenManager.loadAccessToken()?.isNotEmpty() == true | ||
| } | ||
| ) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.