Reset backupV2 credentials on 403.

This commit is contained in:
Greyson Parrelli
2024-05-14 16:12:40 -04:00
committed by Nicholas Tinsley
parent 227a279131
commit d0340d39db
2 changed files with 13 additions and 3 deletions

View File

@@ -65,9 +65,15 @@ object BackupRepository {
private const val VERSION = 1L
private val resetInitializedStateErrorAction: StatusCodeErrorAction = { error ->
if (error.code == 401) {
Log.i(TAG, "Resetting initialized state due to 401.")
SignalStore.backup().backupsInitialized = false
when (error.code) {
401 -> {
Log.i(TAG, "Resetting initialized state due to 401.")
SignalStore.backup().backupsInitialized = false
}
403 -> {
Log.i(TAG, "Bad auth credential. Clearing stored credentials.")
SignalStore.backup().clearAllCredentials()
}
}
}

View File

@@ -152,6 +152,10 @@ internal class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
putString(KEY_CREDENTIALS, JsonUtil.toJson(SerializedCredentials(updated)))
}
fun clearAllCredentials() {
putString(KEY_CREDENTIALS, null)
}
class SerializedCredentials(
@JsonProperty
val credentialsByDay: Map<Long, ArchiveServiceCredential>