Merge branch 'development' into timers
This commit is contained in:
commit
ce001898fd
17 changed files with 229 additions and 38 deletions
|
@ -29,5 +29,6 @@ interface AccountDAO {
|
|||
suspend fun sendRecoveryEmail(email: String)
|
||||
suspend fun signUpWithEmailAndPassword(email: String, password: String)
|
||||
suspend fun deleteAccount()
|
||||
|
||||
suspend fun signOut()
|
||||
}
|
||||
|
|
|
@ -4,4 +4,10 @@ interface UserDAO {
|
|||
|
||||
suspend fun getUsername(): String?
|
||||
suspend fun save(newUsername: String)
|
||||
|
||||
/**
|
||||
* Delete all references to this user in the database. Similar to the deleteCascade in
|
||||
* relational databases.
|
||||
*/
|
||||
suspend fun deleteUserReferences()
|
||||
}
|
|
@ -1,19 +1,13 @@
|
|||
package be.ugent.sel.studeez.domain.implementation
|
||||
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import be.ugent.sel.studeez.R
|
||||
import be.ugent.sel.studeez.common.snackbar.SnackbarManager
|
||||
import be.ugent.sel.studeez.domain.AccountDAO
|
||||
import be.ugent.sel.studeez.domain.UserDAO
|
||||
import com.google.firebase.firestore.DocumentReference
|
||||
import com.google.firebase.firestore.FirebaseFirestore
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.awaitClose
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.tasks.await
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
class FirebaseUserDAO @Inject constructor(
|
||||
private val firestore: FirebaseFirestore,
|
||||
|
@ -34,4 +28,10 @@ class FirebaseUserDAO @Inject constructor(
|
|||
companion object {
|
||||
private const val USER_COLLECTION = "users"
|
||||
}
|
||||
|
||||
override suspend fun deleteUserReferences() {
|
||||
currentUserDocument().delete()
|
||||
.addOnSuccessListener { SnackbarManager.showMessage(R.string.success) }
|
||||
.addOnFailureListener { SnackbarManager.showMessage(R.string.generic_error) }
|
||||
}
|
||||
}
|
Reference in a new issue