diff --git a/src/angular/components/attachments.component.ts b/src/angular/components/attachments.component.ts index af925f23f..58704900a 100644 --- a/src/angular/components/attachments.component.ts +++ b/src/angular/components/attachments.component.ts @@ -35,28 +35,7 @@ export class AttachmentsComponent implements OnInit { protected platformUtilsService: PlatformUtilsService, protected win: Window) { } async ngOnInit() { - this.cipherDomain = await this.loadCipher(); - this.cipher = await this.cipherDomain.decrypt(); - - this.hasUpdatedKey = await this.cryptoService.hasEncKey(); - const canAccessPremium = await this.userService.canAccessPremium(); - this.canAccessAttachments = canAccessPremium || this.cipher.organizationId != null; - - if (!this.canAccessAttachments) { - const confirmed = await this.platformUtilsService.showDialog( - this.i18nService.t('premiumRequiredDesc'), this.i18nService.t('premiumRequired'), - this.i18nService.t('learnMore'), this.i18nService.t('cancel')); - if (confirmed) { - this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=purchase'); - } - } else if (!this.hasUpdatedKey) { - const confirmed = await this.platformUtilsService.showDialog( - this.i18nService.t('updateKey'), this.i18nService.t('featureUnavailable'), - this.i18nService.t('learnMore'), this.i18nService.t('cancel'), 'warning'); - if (confirmed) { - this.platformUtilsService.launchUri('https://help.bitwarden.com/article/update-encryption-key/'); - } - } + await this.init(); } async submit() { @@ -156,6 +135,31 @@ export class AttachmentsComponent implements OnInit { a.downloading = false; } + protected async init() { + this.cipherDomain = await this.loadCipher(); + this.cipher = await this.cipherDomain.decrypt(); + + this.hasUpdatedKey = await this.cryptoService.hasEncKey(); + const canAccessPremium = await this.userService.canAccessPremium(); + this.canAccessAttachments = canAccessPremium || this.cipher.organizationId != null; + + if (!this.canAccessAttachments) { + const confirmed = await this.platformUtilsService.showDialog( + this.i18nService.t('premiumRequiredDesc'), this.i18nService.t('premiumRequired'), + this.i18nService.t('learnMore'), this.i18nService.t('cancel')); + if (confirmed) { + this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=purchase'); + } + } else if (!this.hasUpdatedKey) { + const confirmed = await this.platformUtilsService.showDialog( + this.i18nService.t('updateKey'), this.i18nService.t('featureUnavailable'), + this.i18nService.t('learnMore'), this.i18nService.t('cancel'), 'warning'); + if (confirmed) { + this.platformUtilsService.launchUri('https://help.bitwarden.com/article/update-encryption-key/'); + } + } + } + protected async reuploadCipherAttachment(attachment: AttachmentView, admin: boolean) { const a = (attachment as any); if (attachment.key != null || a.downloading || this.reuploadPromises[attachment.id] != null) { diff --git a/src/angular/components/folder-add-edit.component.ts b/src/angular/components/folder-add-edit.component.ts index 5e6314431..2515459c4 100644 --- a/src/angular/components/folder-add-edit.component.ts +++ b/src/angular/components/folder-add-edit.component.ts @@ -26,16 +26,7 @@ export class FolderAddEditComponent implements OnInit { protected platformUtilsService: PlatformUtilsService) { } async ngOnInit() { - this.editMode = this.folderId != null; - - if (this.editMode) { - this.editMode = true; - this.title = this.i18nService.t('editFolder'); - const folder = await this.folderService.get(this.folderId); - this.folder = await folder.decrypt(); - } else { - this.title = this.i18nService.t('addFolder'); - } + await this.init(); } async submit(): Promise { @@ -77,4 +68,17 @@ export class FolderAddEditComponent implements OnInit { return true; } + + protected async init() { + this.editMode = this.folderId != null; + + if (this.editMode) { + this.editMode = true; + this.title = this.i18nService.t('editFolder'); + const folder = await this.folderService.get(this.folderId); + this.folder = await folder.decrypt(); + } else { + this.title = this.i18nService.t('addFolder'); + } + } } diff --git a/src/angular/components/password-history.component.ts b/src/angular/components/password-history.component.ts index d567d73d6..f227e4ba5 100644 --- a/src/angular/components/password-history.component.ts +++ b/src/angular/components/password-history.component.ts @@ -14,9 +14,7 @@ export class PasswordHistoryComponent implements OnInit { protected i18nService: I18nService, private win: Window) { } async ngOnInit() { - const cipher = await this.cipherService.get(this.cipherId); - const decCipher = await cipher.decrypt(); - this.history = decCipher.passwordHistory == null ? [] : decCipher.passwordHistory; + await this.init(); } copy(password: string) { @@ -26,4 +24,10 @@ export class PasswordHistoryComponent implements OnInit { this.platformUtilsService.showToast('info', null, this.i18nService.t('valueCopied', this.i18nService.t('password'))); } + + protected async init() { + const cipher = await this.cipherService.get(this.cipherId); + const decCipher = await cipher.decrypt(); + this.history = decCipher.passwordHistory == null ? [] : decCipher.passwordHistory; + } }