1
0
mirror of https://github.com/bitwarden/web synced 2026-01-06 10:33:17 +00:00

Move and list ciphers from org subvaults

This commit is contained in:
Kyle Spearrin
2017-03-21 00:05:20 -04:00
parent 22ab5d334e
commit b85a45d8f9
7 changed files with 131 additions and 9 deletions

View File

@@ -0,0 +1,61 @@
angular
.module('bit.vault')
.controller('vaultShareController', function ($scope, apiService, $uibModalInstance, authService, cipherService, loginId, $analytics) {
$analytics.eventTrack('vaultShareController', { category: 'Modal' });
$scope.model = {};
$scope.login = {};
$scope.subvaults = [];
$scope.organizations = [];
apiService.logins.get({ id: loginId }, function (login) {
$scope.login = cipherService.decryptLogin(login);
});
var profile = authService.getUserProfile();
if (profile && profile.organizations) {
var orgs = [];
for (var i = 0; i < profile.organizations.length; i++) {
orgs.push({
id: profile.organizations[i].id,
name: profile.organizations[i].name
});
if (i === 0) {
$scope.model.organizationId = profile.organizations[i].id;
}
}
$scope.organizations = orgs;
apiService.subvaults.listMe(function (response) {
var subvaults = [];
for (var i = 0; i < response.Data.length; i++) {
var decSubvault = cipherService.decryptSubvault(response.Data[i]);
decSubvault.organizationId = response.Data[i].OrganizationId;
subvaults.push(decSubvault);
}
$scope.subvaults = subvaults;
});
}
$scope.submitPromise = null;
$scope.submit = function (model) {
$scope.login.organizationId = model.organizationId;
var request = {
subvaultIds: model.subvaultIds,
cipher: cipherService.encryptLogin($scope.login)
};
$scope.savePromise = apiService.ciphers.move({ id: loginId }, request, function (response) {
$analytics.eventTrack('Shared Login');
$uibModalInstance.close();
}).$promise;
};
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
});