1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-24 12:06:15 +01:00

check for encKey when using attachments

This commit is contained in:
Kyle Spearrin 2017-07-12 13:49:28 -04:00
parent 81ad214f2f
commit 94e4ea656e
2 changed files with 32 additions and 1 deletions

View File

@ -754,5 +754,13 @@
"maxFileSize": { "maxFileSize": {
"message": "Maximum file size is 100 MB.", "message": "Maximum file size is 100 MB.",
"description": "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."
} }
} }

View File

@ -2,7 +2,7 @@ angular
.module('bit.vault') .module('bit.vault')
.controller('vaultAttachmentsController', function ($scope, $state, $stateParams, loginService, $q, toastr, .controller('vaultAttachmentsController', function ($scope, $state, $stateParams, loginService, $q, toastr,
SweetAlert, utilsService, $analytics, i18nService) { SweetAlert, utilsService, $analytics, i18nService, cryptoService) {
$scope.i18n = i18nService; $scope.i18n = i18nService;
utilsService.initListSectionItemListeners($(document), angular); 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.submitPromise = null;
$scope.submit = function () { $scope.submit = function () {
if (!$scope.canUseAttachments) {
toastr.error(i18nService.updateKey);
return;
}
var files = document.getElementById('file').files; var files = document.getElementById('file').files;
if (!files || !files.length) { if (!files || !files.length) {
toastr.error(i18nService.selectFile, i18nService.errorsOccurred); toastr.error(i18nService.selectFile, i18nService.errorsOccurred);