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