From 6d8b1564551b1f0960f3b1c5bb4c50834928e0c5 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 14 Nov 2018 15:54:13 -0500 Subject: [PATCH] old attachments check when rotating enc key --- .../settings/change-password.component.html | 2 +- src/app/settings/change-password.component.ts | 24 ++++++++++++++++++- src/locales/en/messages.json | 7 ++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/app/settings/change-password.component.html b/src/app/settings/change-password.component.html index c172141f23..092e5bcba5 100644 --- a/src/app/settings/change-password.component.html +++ b/src/app/settings/change-password.component.html @@ -29,7 +29,7 @@
+ (change)="rotateEncKeyClicked()"> diff --git a/src/app/settings/change-password.component.ts b/src/app/settings/change-password.component.ts index 7023af5de7..c48516407b 100644 --- a/src/app/settings/change-password.component.ts +++ b/src/app/settings/change-password.component.ts @@ -128,8 +128,30 @@ export class ChangePasswordComponent implements OnInit { }, 300); } - async showEncKeyWarning() { + async rotateEncKeyClicked() { if (this.rotateEncKey) { + const ciphers = await this.cipherService.getAllDecrypted(); + let hasOldAttachments = false; + if (ciphers != null) { + for (let i = 0; i < ciphers.length; i++) { + if (ciphers[i].organizationId == null && ciphers[i].hasOldAttachments) { + hasOldAttachments = true; + break; + } + } + } + + if (hasOldAttachments) { + const learnMore = await this.platformUtilsService.showDialog( + this.i18nService.t('oldAttachmentsNeedFixDesc'), null, + this.i18nService.t('learnMore'), this.i18nService.t('close'), 'warning'); + if (learnMore) { + this.platformUtilsService.launchUri('https://help.bitwarden.com/article/attachments/'); + } + this.rotateEncKey = false; + return; + } + const result = await this.platformUtilsService.showDialog( this.i18nService.t('updateEncryptionKeyWarning') + ' ' + this.i18nService.t('rotateEncKeyConfirmation'), this.i18nService.t('rotateEncKeyTitle'), diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index c3008b30c9..94a5c751b0 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -2541,12 +2541,15 @@ "message": "Are you sure you want to rotate your account's encryption key?" }, "attachmentsNeedFix": { - "message": "This item has old attachments that need to be fixed." + "message": "This item has old file attachments that need to be fixed." }, "attachmentFixDesc": { - "message": "This is an old attachment the needs to be fixed. Click to learn more." + "message": "This is an old file attachment the needs to be fixed. Click to learn more." }, "fix": { "message": "Fix" + }, + "oldAttachmentsNeedFixDesc": { + "message": "There are old file attachments in your vault that need to be fixed before you can rotate your account's encryption key." } }