1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-10 06:08:34 +02:00
bitwarden-browser/src/app/organization/organizationSubvaultsEditController.js
2017-03-29 22:23:00 -04:00

27 lines
1.1 KiB
JavaScript

angular
.module('bit.organization')
.controller('organizationSubvaultsEditController', function ($scope, $state, $uibModalInstance, apiService, cipherService,
$analytics, id) {
$scope.subvault = {};
$uibModalInstance.opened.then(function () {
apiService.subvaults.get({ orgId: $state.params.orgId, id: id }, function (subvault) {
$scope.subvault = cipherService.decryptSubvault(subvault);
});
});
$scope.submit = function (model) {
var subvault = cipherService.encryptSubvault(model, $state.params.orgId);
$scope.submitPromise = apiService.subvaults.put({ orgId: $state.params.orgId }, subvault, function (response) {
$analytics.eventTrack('Edited Subvault');
var decSubvault = cipherService.decryptSubvault(response, $state.params.orgId, true);
$uibModalInstance.close(decSubvault);
}).$promise;
};
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
});