Fix unsharing

This commit is contained in:
brantje 2016-10-05 20:07:13 +02:00
parent 7d3d67c896
commit 1c55e6dfa9
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
4 changed files with 21 additions and 4 deletions

View file

@ -107,7 +107,7 @@ class CredentialController extends ApiController {
$credential_id, $custom_fields, $delete_time,
$description, $email, $expire_time, $favicon, $files, $guid,
$hidden, $label, $otp, $password, $renew_interval,
$tags, $url, $username, $vault_id, $revision_created, $shared_key, $acl) {
$tags, $url, $username, $vault_id, $revision_created, $shared_key, $acl, $unshare_action) {
$storedCredential = $this->credentialService->getCredentialById($credential_id, $this->userId);
@ -221,6 +221,10 @@ class CredentialController extends ApiController {
if($storedCredential->getSharedKey() === null){
$storedCredential->setSharedKey($shared_key);
}
if($unshare_action){
$storedCredential->setSharedKey('');
$credential['shared_key'] = '';
}
$this->credentialRevisionService->createRevision($storedCredential, $storedCredential->getUserId(), $credential_id, $this->userId);
$credential = $this->credentialService->updateCredential($credential);

View file

@ -180,7 +180,9 @@ angular.module('passmanApp')
$scope.unshareCredential = function (credential) {
ShareService.unshareCredential(credential);
var _credential = angular.copy(credential);
var enc_key = EncryptService.decryptString(angular.copy(_credential.shared_key));
_credential.shared_key = null;
_credential.unshare_action = true;
CredentialService.updateCredential(_credential).then(function () {
NotificationService.showNotification('Credential unshared', 4000)
});
@ -189,11 +191,22 @@ angular.module('passmanApp')
var _file = $scope.storedCredential.files[f];
FileService.getFile(_file).then(function (fileData) {
//Decrypt with old key
fileData.filename = EncryptService.decryptString(fileData.filename);
fileData.filename = EncryptService.decryptString(fileData.filename, enc_key);
fileData.file_data = EncryptService.decryptString(fileData.file_data);
FileService.updateFile(fileData, $scope.active_vault.vaultKey);
})
}
CredentialService.getRevisions($scope.storedCredential.guid).then(function (revisions) {
for (var r = 0; r < revisions.length; r++) {
var _revision = revisions[r];
//Decrypt!
_revision.credential_data = ShareService.decryptSharedCredential(_revision.credential_data, enc_key);
_revision.credential_data = CredentialService.encryptCredential(_revision.credential_data);
console.log('Used key for encrypting history ', enc_key);
CredentialService.updateRevision(_revision);
}
});
};
/**

File diff suppressed because one or more lines are too long

View file

@ -74,7 +74,7 @@
<span class="icon">
<i class="fa fa-lock" ng-if="!credential.acl && !credential.shared_key"></i>
<i class="fa fa-share-alt" ng-if="credential.acl"></i>
<i class="fa fa-share-alt-square" ng-if="credential.shared_key != null"></i>
<i class="fa fa-share-alt-square" ng-if="credential.shared_key"></i>
</span>
<span class="label">{{ ::credential.label}}</span>
<span class="tags">