From 1c55e6dfa981bb112c406267a0d4fa9b8858e5b8 Mon Sep 17 00:00:00 2001 From: brantje Date: Wed, 5 Oct 2016 20:07:13 +0200 Subject: [PATCH] Fix unsharing --- controller/credentialcontroller.php | 6 +++++- js/app/controllers/share.js | 15 ++++++++++++++- js/templates.js | 2 +- templates/views/show_vault.html | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/controller/credentialcontroller.php b/controller/credentialcontroller.php index b6fcb60f..22718bd3 100644 --- a/controller/credentialcontroller.php +++ b/controller/credentialcontroller.php @@ -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); diff --git a/js/app/controllers/share.js b/js/app/controllers/share.js index 69d546ae..6bdfeb58 100644 --- a/js/app/controllers/share.js +++ b/js/app/controllers/share.js @@ -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); + } + }); }; /** diff --git a/js/templates.js b/js/templates.js index bfa0c737..35325dfd 100644 --- a/js/templates.js +++ b/js/templates.js @@ -113,7 +113,7 @@ angular.module('views/share_credential.html', []).run(['$templateCache', functio angular.module('views/show_vault.html', []).run(['$templateCache', function($templateCache) { 'use strict'; $templateCache.put('views/show_vault.html', - '
Showing deleted since: All time {{delete_time | date:\'dd-MM-yyyy @ HH:mm:ss\'}} Showing {{filtered_credentials.length}} of {{active_vault.credentials.length}} credentials
+
{{filtered_credentials}}
{{ ::credential.label}} {{ ::tag.text}}
  • {{ ::credential.label}}
    {{ ::tag.text}}
Label{{selectedCredential.label}}
Account
Password
OTP
E-mail
URL
Files
{{field.label}}
Expire time{{selectedCredential.expire_time * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}
Changed{{selectedCredential.changed * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}
Created{{selectedCredential.created * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}
{{tag.text}}
'); + '
Showing deleted since: All time {{delete_time | date:\'dd-MM-yyyy @ HH:mm:ss\'}} Showing {{filtered_credentials.length}} of {{active_vault.credentials.length}} credentials
+
{{filtered_credentials}}
{{ ::credential.label}} {{ ::tag.text}}
  • {{ ::credential.label}}
    {{ ::tag.text}}
Label{{selectedCredential.label}}
Account
Password
OTP
E-mail
URL
Files
{{field.label}}
Expire time{{selectedCredential.expire_time * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}
Changed{{selectedCredential.changed * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}
Created{{selectedCredential.created * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}
{{tag.text}}
'); }]); angular.module('views/vaults.html', []).run(['$templateCache', function($templateCache) { diff --git a/templates/views/show_vault.html b/templates/views/show_vault.html index a83ed8e8..95a63de2 100644 --- a/templates/views/show_vault.html +++ b/templates/views/show_vault.html @@ -74,7 +74,7 @@ - + {{ ::credential.label}}