Skip to content

Commit

Permalink
Handle keychain errors when removing credentials
Browse files Browse the repository at this point in the history
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
  • Loading branch information
charlag committed Jan 20, 2025
1 parent 11391f4 commit c21e3e1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/common/login/CredentialRemovalHandler.ts
Original file line number Diff line number Diff line change
@@ -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<void>
Expand All @@ -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)
Expand Down

0 comments on commit c21e3e1

Please sign in to comment.