convert share from logins to ciphers
This commit is contained in:
parent
422b48fa36
commit
7a36f13034
|
@ -310,10 +310,10 @@
|
|||
$scope.share = function (cipher) {
|
||||
var modal = $uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: 'app/vault/views/vaultShareLogin.html',
|
||||
controller: 'vaultShareLoginController',
|
||||
templateUrl: 'app/vault/views/vaultShareCipher.html',
|
||||
controller: 'vaultShareCipherController',
|
||||
resolve: {
|
||||
loginId: function () { return cipher.id; }
|
||||
cipherId: function () { return cipher.id; }
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
angular
|
||||
.module('bit.vault')
|
||||
|
||||
.controller('vaultShareLoginController', function ($scope, apiService, $uibModalInstance, authService, cipherService,
|
||||
loginId, $analytics, $state, cryptoService, $q, toastr) {
|
||||
$analytics.eventTrack('vaultShareLoginController', { category: 'Modal' });
|
||||
.controller('vaultShareCipherController', function ($scope, apiService, $uibModalInstance, authService, cipherService,
|
||||
cipherId, $analytics, $state, cryptoService, $q, toastr) {
|
||||
$analytics.eventTrack('vaultShareCipherController', { category: 'Modal' });
|
||||
$scope.model = {};
|
||||
$scope.login = {};
|
||||
$scope.cipher = {};
|
||||
$scope.collections = [];
|
||||
$scope.selectedCollections = {};
|
||||
$scope.organizations = [];
|
||||
|
@ -14,13 +14,13 @@
|
|||
$scope.loading = true;
|
||||
$scope.readOnly = false;
|
||||
|
||||
apiService.ciphers.get({ id: loginId }).$promise.then(function (login) {
|
||||
$scope.readOnly = !login.Edit;
|
||||
if (login.Edit) {
|
||||
$scope.login = cipherService.decryptLogin(login);
|
||||
apiService.ciphers.get({ id: cipherId }).$promise.then(function (cipher) {
|
||||
$scope.readOnly = !cipher.Edit;
|
||||
if (cipher.Edit) {
|
||||
$scope.cipher = cipherService.decryptCipher(cipher);
|
||||
}
|
||||
|
||||
return login.Edit;
|
||||
return cipher.Edit;
|
||||
}).then(function (canEdit) {
|
||||
$scope.loading = false;
|
||||
if (!canEdit) {
|
||||
|
@ -110,8 +110,8 @@
|
|||
|
||||
var errorOnUpload = false;
|
||||
var attachmentSharePromises = [];
|
||||
if ($scope.login.attachments) {
|
||||
for (var i = 0; i < $scope.login.attachments.length; i++) {
|
||||
if ($scope.cipher.attachments) {
|
||||
for (var i = 0; i < $scope.cipher.attachments.length; i++) {
|
||||
(function (attachment) {
|
||||
var promise = cipherService.downloadAndDecryptAttachment(null, attachment, false)
|
||||
.then(function (decData) {
|
||||
|
@ -127,7 +127,7 @@
|
|||
fd.append('data', blob, encFilename);
|
||||
|
||||
return apiService.ciphers.postShareAttachment({
|
||||
id: loginId,
|
||||
id: cipherId,
|
||||
attachmentId: attachment.id,
|
||||
orgId: model.organizationId
|
||||
}, fd).$promise;
|
||||
|
@ -135,7 +135,7 @@
|
|||
errorOnUpload = true;
|
||||
});
|
||||
attachmentSharePromises.push(promise);
|
||||
})($scope.login.attachments[i]);
|
||||
})($scope.cipher.attachments[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,11 +144,11 @@
|
|||
return;
|
||||
}
|
||||
|
||||
$scope.login.organizationId = model.organizationId;
|
||||
$scope.cipher.organizationId = model.organizationId;
|
||||
|
||||
var request = {
|
||||
collectionIds: [],
|
||||
cipher: cipherService.encryptLogin($scope.login, null, true)
|
||||
cipher: cipherService.encryptCipher($scope.cipher, $scope.cipher.type, null, true)
|
||||
};
|
||||
|
||||
for (var id in $scope.selectedCollections) {
|
||||
|
@ -157,10 +157,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
return apiService.ciphers.putShare({ id: loginId }, request).$promise;
|
||||
return apiService.ciphers.putShare({ id: cipherId }, request).$promise;
|
||||
}).then(function (response) {
|
||||
$analytics.eventTrack('Shared Login');
|
||||
toastr.success('Login has been shared.');
|
||||
$analytics.eventTrack('Shared Cipher');
|
||||
toastr.success('Item has been shared.');
|
||||
$uibModalInstance.close(model.organizationId);
|
||||
});
|
||||
};
|
|
@ -1,10 +1,10 @@
|
|||
<div class="modal-header">
|
||||
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title"><i class="fa fa-share-alt"></i> Share Login <small>{{login.name}}</small></h4>
|
||||
<h4 class="modal-title"><i class="fa fa-share-alt"></i> Share Item <small>{{cipher.name}}</small></h4>
|
||||
</div>
|
||||
<form name="form" ng-submit="form.$valid && submit(model)" api-form="submitPromise" autocomplete="off">
|
||||
<div class="modal-body">
|
||||
<p>Choose an organization that you wish to share this login with.</p>
|
||||
<p>Choose an organization that you wish to share this item with.</p>
|
||||
<div class="callout callout-danger validation-errors" ng-show="form.$errors">
|
||||
<h4>Errors have occurred</h4>
|
||||
<ul>
|
||||
|
@ -14,7 +14,7 @@
|
|||
<p ng-show="loading">Loading...</p>
|
||||
<div ng-show="!loading && !organizations.length" class="callout callout-default">
|
||||
<h4><i class="fa fa-info-circle"></i> No Organizations</h4>
|
||||
<p>You do not belong to any organizations. Organizations allow you to share logins with other bitwarden users.</p>
|
||||
<p>You do not belong to any organizations. Organizations allow you to share items with other bitwarden users.</p>
|
||||
<a ng-click="createOrg()" class="btn btn-default btn-flat">
|
||||
Create an Organization
|
||||
</a>
|
||||
|
@ -72,4 +72,4 @@
|
|||
</button>
|
||||
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
|
@ -214,7 +214,7 @@
|
|||
<script src="app/vault/vaultAddCipherController.js"></script>
|
||||
<script src="app/vault/vaultEditFolderController.js"></script>
|
||||
<script src="app/vault/vaultAddFolderController.js"></script>
|
||||
<script src="app/vault/vaultShareLoginController.js"></script>
|
||||
<script src="app/vault/vaultShareCipherController.js"></script>
|
||||
<script src="app/vault/vaultSharedController.js"></script>
|
||||
<script src="app/vault/vaultLoginCollectionsController.js"></script>
|
||||
<script src="app/vault/vaultMoveLoginsController.js"></script>
|
||||
|
|
Loading…
Reference in New Issue