From c9a1bfaf00bf680c858c46f4b66a985c4ee419cf Mon Sep 17 00:00:00 2001 From: ivk Date: Mon, 20 Jan 2025 10:58:25 +0100 Subject: [PATCH] Handle keychain errors when removing credentials This commit adds minimal handling for the case when the device key is corrupted in some way, and we try to remove the local SSE data. This does not address the issue that the local data will still be unusable, this needs to be addressed in a more general way separately. Close #8280 --- src/common/login/CredentialRemovalHandler.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common/login/CredentialRemovalHandler.ts b/src/common/login/CredentialRemovalHandler.ts index 2472b8bbc3c2..0b8951cd7c1a 100644 --- a/src/common/login/CredentialRemovalHandler.ts +++ b/src/common/login/CredentialRemovalHandler.ts @@ -1,6 +1,7 @@ import { NativePushServiceApp } from "../native/main/NativePushServiceApp.js" import { ConfigurationDatabase } from "../api/worker/facades/lazy/ConfigurationDatabase.js" import { CredentialsInfo } from "../native/common/generatedipc/CredentialsInfo.js" +import { DeviceStorageUnavailableError } from "../api/common/error/DeviceStorageUnavailableError" export interface CredentialRemovalHandler { onCredentialsRemoved(credentialInfo: CredentialsInfo): Promise @@ -19,7 +20,15 @@ export class AppsCredentialRemovalHandler implements CredentialRemovalHandler { async onCredentialsRemoved({ login, userId }: CredentialsInfo) { await this.pushApp.invalidateAlarmsForUser(userId) - await this.pushApp.removeUserFromNotifications(userId) + try { + await this.pushApp.removeUserFromNotifications(userId) + } catch (e) { + if (e instanceof DeviceStorageUnavailableError) { + console.warn("Could not remove SSE data: ", e) + } else { + throw e + } + } await this.configFacade.delete(userId) await this.appSpecificCredentialRemovalActions(login, userId)