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

premium check updates

This commit is contained in:
Kyle Spearrin 2017-07-26 10:07:12 -04:00
parent d4759d4056
commit a1dfd7493a
3 changed files with 28 additions and 25 deletions

View File

@ -8,15 +8,16 @@
$scope.readOnly = true; $scope.readOnly = true;
$scope.loading = true; $scope.loading = true;
$scope.isPremium = true; $scope.isPremium = true;
$scope.canUseAttachments = true;
var closing = false; var closing = false;
authService.getUserProfile().then(function (profile) { authService.getUserProfile().then(function (profile) {
$scope.isPremium = profile.premium; $scope.isPremium = profile.premium;
}); return apiService.logins.get({ id: loginId }).$promise;
}).then(function (login) {
apiService.logins.get({ id: loginId }, function (login) {
$scope.login = cipherService.decryptLogin(login); $scope.login = cipherService.decryptLogin(login);
$scope.readOnly = !login.Edit; $scope.readOnly = !login.Edit;
$scope.canUseAttachments = $scope.isPremium || $scope.login.organizationId;
$scope.loading = false; $scope.loading = false;
}, function () { }, function () {
$scope.loading = false; $scope.loading = false;
@ -57,7 +58,7 @@
$scope.download = function (attachment) { $scope.download = function (attachment) {
attachment.loading = true; attachment.loading = true;
if (!$scope.login.organizationId && !$scope.isPremium) { if (!$scope.canUseAttachments) {
attachment.loading = false; attachment.loading = false;
alert('Premium membership is required to use this feature.'); alert('Premium membership is required to use this feature.');
return; return;

View File

@ -206,25 +206,27 @@
orgUseStorage: login.organizationId && !!profile.organizations[login.organizationId].maxStorageGb orgUseStorage: login.organizationId && !!profile.organizations[login.organizationId].maxStorageGb
}; };
}).then(function (perms) { }).then(function (perms) {
if (login.organizationId && !perms.orgUseStorage) { if (!login.hasAttachments) {
$uibModal.open({ if (login.organizationId && !perms.orgUseStorage) {
animation: true, $uibModal.open({
templateUrl: 'app/views/paidOrgRequired.html', animation: true,
controller: 'paidOrgRequiredController', templateUrl: 'app/views/paidOrgRequired.html',
resolve: { controller: 'paidOrgRequiredController',
orgId: function () { return login.organizationId; } resolve: {
} orgId: function () { return login.organizationId; }
}); }
return; });
} return;
}
if (!login.organizationId && !perms.isPremium) { if (!login.organizationId && !perms.isPremium) {
$uibModal.open({ $uibModal.open({
animation: true, animation: true,
templateUrl: 'app/views/premiumRequired.html', templateUrl: 'app/views/premiumRequired.html',
controller: 'premiumRequiredController' controller: 'premiumRequiredController'
}); });
return; return;
}
} }
if (!login.organizationId && !cryptoService.getEncKey()) { if (!login.organizationId && !cryptoService.getEncKey()) {

View File

@ -48,7 +48,7 @@
<div ng-if="!readOnly"> <div ng-if="!readOnly">
<hr /> <hr />
<h4>Add New Attachment</h4> <h4>Add New Attachment</h4>
<div class="callout callout-warning" ng-if="!isPremium"> <div class="callout callout-warning" ng-if="!canUseAttachments">
<h4>Premium Membership Required</h4> <h4>Premium Membership Required</h4>
<p>Premium membership is required to use this feature.</p> <p>Premium membership is required to use this feature.</p>
<button type="button" class="btn btn-default btn-flat" ng-click="showUpgrade()">Learn More</button> <button type="button" class="btn btn-default btn-flat" ng-click="showUpgrade()">Learn More</button>
@ -59,7 +59,7 @@
<li ng-repeat="e in form.$errors">{{e}}</li> <li ng-repeat="e in form.$errors">{{e}}</li>
</ul> </ul>
</div> </div>
<div class="form-group" show-error ng-if="isPremium"> <div class="form-group" show-error ng-if="canUseAttachments">
<label for="file" class="sr-only">File</label> <label for="file" class="sr-only">File</label>
<input type="file" id="file" name="file" /> <input type="file" id="file" name="file" />
<p class="help-block">Maximum size per file is 100 MB.</p> <p class="help-block">Maximum size per file is 100 MB.</p>
@ -67,7 +67,7 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="form.$loading" ng-if="!readOnly && isPremium"> <button type="submit" class="btn btn-primary btn-flat" ng-disabled="form.$loading" ng-if="!readOnly && canUseAttachments">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="form.$loading"></i>Save <i class="fa fa-refresh fa-spin loading-icon" ng-show="form.$loading"></i>Save
</button> </button>
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button> <button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>