From 94e4ea656e46edc674c8ba19216caa267abdf50a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 12 Jul 2017 13:49:28 -0400 Subject: [PATCH] check for encKey when using attachments --- src/_locales/en/messages.json | 8 ++++++ .../app/vault/vaultAttachmentsController.js | 25 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index e7d0924c43..739fbb2d1d 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -754,5 +754,13 @@ "maxFileSize": { "message": "Maximum file size is 100 MB.", "description": "Maximum file size is 100 MB." + }, + "featureUnavailable": { + "message": "Feature Unavailable", + "description": "Feature Unavailable" + }, + "updateKey": { + "message": "You cannot use this feature until you update your encryption key.", + "description": "You cannot use this feature until you update your encryption key." } } diff --git a/src/popup/app/vault/vaultAttachmentsController.js b/src/popup/app/vault/vaultAttachmentsController.js index 85a719da93..9e930fa07b 100644 --- a/src/popup/app/vault/vaultAttachmentsController.js +++ b/src/popup/app/vault/vaultAttachmentsController.js @@ -2,7 +2,7 @@ angular .module('bit.vault') .controller('vaultAttachmentsController', function ($scope, $state, $stateParams, loginService, $q, toastr, - SweetAlert, utilsService, $analytics, i18nService) { + SweetAlert, utilsService, $analytics, i18nService, cryptoService) { $scope.i18n = i18nService; utilsService.initListSectionItemListeners($(document), angular); @@ -12,8 +12,31 @@ angular }); }); + $scope.canUseAttachments = false; + cryptoService.getEncKey().then(function (key) { + $scope.canUseAttachments = !!key; + if (!$scope.canUseAttachments) { + SweetAlert.swal({ + title: i18nService.featureUnavailable, + text: i18nService.updateKey, + showCancelButton: true, + confirmButtonText: i18nService.learnMore, + cancelButtonText: i18nService.cancel + }, function (confirmed) { + if (confirmed) { + chrome.tabs.create({ url: 'https://help.bitwarden.com' }); + } + }); + } + }); + $scope.submitPromise = null; $scope.submit = function () { + if (!$scope.canUseAttachments) { + toastr.error(i18nService.updateKey); + return; + } + var files = document.getElementById('file').files; if (!files || !files.length) { toastr.error(i18nService.selectFile, i18nService.errorsOccurred);