-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/jaino/#86
- Loading branch information
Showing
11 changed files
with
64 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 24 additions & 2 deletions
26
core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/DeleteUserUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
package com.wap.wapp.core.domain.usecase.auth | ||
|
||
import com.wap.wapp.core.data.repository.auth.AuthRepository | ||
import com.wap.wapp.core.data.repository.management.ManagementRepository | ||
import com.wap.wapp.core.data.repository.user.UserRepository | ||
import com.wap.wapp.core.domain.usecase.user.GetUserRoleUseCase | ||
import com.wap.wapp.core.model.user.UserRole | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class DeleteUserUseCase @Inject constructor( | ||
private val authRepository: AuthRepository, | ||
private val userRepository: UserRepository, | ||
private val managementRepository: ManagementRepository, | ||
private val getUserRoleUseCase: GetUserRoleUseCase, | ||
) { | ||
suspend operator fun invoke(): Result<Unit> = | ||
authRepository.deleteUser() | ||
suspend operator fun invoke(userId: String): Result<Unit> = runCatching { | ||
val userRole = getUserRoleUseCase().getOrThrow() | ||
when (userRole) { | ||
UserRole.GUEST -> { return@runCatching } | ||
|
||
UserRole.MEMBER -> { | ||
userRepository.deleteUserProfile(userId) | ||
} | ||
|
||
UserRole.MANAGER -> { | ||
userRepository.deleteUserProfile(userId) | ||
managementRepository.deleteManager(userId) | ||
} | ||
} | ||
|
||
authRepository.deleteUser().getOrThrow() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters