mirror of
https://github.com/eugeny/tabby
synced 2026-08-23 06:16:43 +00:00
fix: handle vault unlock modal cancellation gracefully (#11356)
This commit is contained in:
@@ -2260,6 +2260,10 @@ msgstr ""
|
||||
msgid "Thank you for downloading Tabby!"
|
||||
msgstr ""
|
||||
|
||||
#: tabby-core/src/services/config.service.ts:471
|
||||
msgid "The vault must be unlocked to load your configuration."
|
||||
msgstr ""
|
||||
|
||||
#: locale/tmp-html/tabby-settings/src/components/windowSettingsTab.component.html:5
|
||||
msgid "Theme"
|
||||
msgstr ""
|
||||
|
||||
@@ -466,6 +466,24 @@ export class ConfigService {
|
||||
decryptedVault = await this.vault.decrypt(store.vault, passphrase)
|
||||
break
|
||||
} catch (e) {
|
||||
if (e.toString().includes('Vault unlock cancelled')) {
|
||||
const cancelResult = await this.platform.showMessageBox({
|
||||
type: 'warning',
|
||||
message: this.translate.instant('Vault is locked'),
|
||||
detail: this.translate.instant('The vault must be unlocked to load your configuration.'),
|
||||
buttons: [
|
||||
this.translate.instant('Try again'),
|
||||
this.translate.instant('Quit'),
|
||||
],
|
||||
defaultId: 0,
|
||||
cancelId: 1,
|
||||
})
|
||||
if (cancelResult.response === 1) {
|
||||
this.platform.quit()
|
||||
return {}
|
||||
}
|
||||
continue
|
||||
}
|
||||
let result = await this.platform.showMessageBox({
|
||||
type: 'error',
|
||||
message: this.translate.instant('Could not decrypt config'),
|
||||
|
||||
@@ -178,7 +178,11 @@ export class VaultService {
|
||||
async getPassphrase (): Promise<string> {
|
||||
if (!_rememberedPassphrase) {
|
||||
const modal = this.ngbModal.open(UnlockVaultModalComponent)
|
||||
const { passphrase, rememberFor } = await modal.result
|
||||
const result = await modal.result.catch(() => null)
|
||||
if (!result) {
|
||||
throw new Error('Vault unlock cancelled')
|
||||
}
|
||||
const { passphrase, rememberFor } = result
|
||||
setTimeout(() => {
|
||||
_rememberedPassphrase = null
|
||||
// avoid multiple consequent prompts
|
||||
|
||||
Reference in New Issue
Block a user