Delete the users vault data on logout (#418)

This commit is contained in:
David Perez
2023-12-19 12:29:34 -06:00
committed by Álison Fernandes
parent 772d6693a6
commit f2f3a6a386
5 changed files with 32 additions and 1 deletions

View File

@@ -267,6 +267,9 @@ class AuthRepositoryImpl constructor(
authDiskSource.userState = null
}
// Delete all the vault data
vaultRepository.deleteVaultData(userId)
// Lock the vault for the logged out user
vaultRepository.lockVaultIfNecessary(userId)

View File

@@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.StateFlow
/**
* Responsible for managing vault data inside the network layer.
*/
@Suppress("TooManyFunctions")
interface VaultRepository {
/**
@@ -53,6 +54,11 @@ interface VaultRepository {
*/
fun clearUnlockedData()
/**
* Completely remove any persisted data from the vault.
*/
fun deleteVaultData(userId: String)
/**
* Attempt to sync the vault data.
*/

View File

@@ -143,6 +143,12 @@ class VaultRepositoryImpl(
sendDataMutableStateFlow.update { DataState.Loading }
}
override fun deleteVaultData(userId: String) {
scope.launch {
vaultDiskSource.deleteVaultData(userId)
}
}
override fun sync() {
if (!syncJob.isCompleted || willSyncAfterUnlock) return
val userId = activeUserId ?: return