1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-18 02:41:15 +02:00

show premium required message on attachments

This commit is contained in:
Kyle Spearrin 2017-07-26 11:21:57 -04:00
parent 4d86987779
commit b5e358bdec

View File

@ -7,33 +7,52 @@ angular
utilsService.initListSectionItemListeners($(document), angular); utilsService.initListSectionItemListeners($(document), angular);
$scope.isPremium = tokenService.getPremium(); $scope.isPremium = tokenService.getPremium();
$scope.canAccessAttachments = $scope.isPremium;
$scope.hasUpdatedKey = false;
loginService.get($stateParams.id, function (login) { loginService.get($stateParams.id, function (login) {
$q.when(login.decrypt()).then(function (model) { $q.when(login.decrypt()).then(function (model) {
$scope.login = model; $scope.login = model;
}); $scope.canAccessAttachments = $scope.isPremium || !!$scope.login.organizationId;
});
$scope.canUseAttachments = false; if (!$scope.canAccessAttachments) {
cryptoService.getEncKey().then(function (key) { SweetAlert.swal({
$scope.canUseAttachments = !!key; title: i18nService.premiumRequired,
if (!$scope.canUseAttachments && $scope.isPremium) { text: i18nService.premiumRequiredDesc,
SweetAlert.swal({ showCancelButton: true,
title: i18nService.featureUnavailable, confirmButtonText: i18nService.learnMore,
text: i18nService.updateKey, cancelButtonText: i18nService.cancel
showCancelButton: true, }, function (confirmed) {
confirmButtonText: i18nService.learnMore, if (confirmed) {
cancelButtonText: i18nService.cancel chrome.tabs.create({ url: 'https://vault.bitwarden.com/#/?premium=purchase' });
}, function (confirmed) { }
if (confirmed) { });
chrome.tabs.create({ url: 'https://help.bitwarden.com/article/update-encryption-key/' }); return;
} }
}); else {
} cryptoService.getEncKey().then(function (key) {
$scope.hasUpdatedKey = !!key;
if (!$scope.hasUpdatedKey) {
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/article/update-encryption-key/' });
}
});
}
});
}
});
}); });
$scope.submitPromise = null; $scope.submitPromise = null;
$scope.submit = function () { $scope.submit = function () {
if (!$scope.canUseAttachments) { if (!$scope.hasUpdatedKey) {
toastr.error(i18nService.updateKey); toastr.error(i18nService.updateKey);
return; return;
} }