From 94c418bd5cea37967f2bc5537db74dfe5e073657 Mon Sep 17 00:00:00 2001 From: brantje Date: Wed, 5 Oct 2016 18:52:14 +0200 Subject: [PATCH] Fix error 500 --- controller/credentialcontroller.php | 8 ++++---- js/app/controllers/revision.js | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/controller/credentialcontroller.php b/controller/credentialcontroller.php index 53af6fbd..176038f4 100644 --- a/controller/credentialcontroller.php +++ b/controller/credentialcontroller.php @@ -36,14 +36,14 @@ class CredentialController extends ApiController { public function __construct($AppName, IRequest $request, - IUser $UserId, + $userId, CredentialService $credentialService, ActivityService $activityService, CredentialRevisionService $credentialRevisionService, ShareService $sharingService ) { parent::__construct($AppName, $request); - $this->userId = $UserId; + $this->userId = $userId; $this->credentialService = $credentialService; $this->activityService = $activityService; $this->credentialRevisionService = $credentialRevisionService; @@ -255,11 +255,11 @@ class CredentialController extends ApiController { } // If the request was made by the owner of the credential - if ($this->userId->getUID() == $credential->getUserId()) { + if ($this->userId == $credential->getUserId()) { $result = $this->credentialRevisionService->getRevisions($credential->getId(), $this->userId); } else { - $acl = $this->sharingService->getACL($this->userId->getUID(), $credential_guid); + $acl = $this->sharingService->getACL($this->userId, $credential_guid); if ($acl->hasPermission(SharingACL::HISTORY)){ $result = $this->credentialRevisionService->getRevisions($credential->getId()); } diff --git a/js/app/controllers/revision.js b/js/app/controllers/revision.js index c5a54b17..a986e598 100644 --- a/js/app/controllers/revision.js +++ b/js/app/controllers/revision.js @@ -89,11 +89,24 @@ angular.module('passmanApp') }; $scope.restoreRevision = function (revision) { + var key; var _revision = angular.copy(revision); var _credential = _revision.credential_data; - //@TODO make sure the shared key doesn't get restored - _credential.revision_created = $filter('date')(_revision.created * 1000 , "dd-MM-yyyy @ HH:mm:ss"); - CredentialService.updateCredential(_credential).then(function (result) { + + if(!$scope.storedCredential.hasOwnProperty('acl') && $scope.storedCredential.hasOwnProperty('shared_key')){ + key = EncryptService.decryptString(angular.copy($scope.storedCredential.shared_key)); + } + if($scope.storedCredential.hasOwnProperty('acl')){ + key = EncryptService.decryptString(angular.copy($scope.storedCredential.acl.shared_key)); + } + if(key){ + _credential = ShareService.encryptSharedCredential($scope.storedCredential, key); + + } + delete _credential.shared_key; + + //_credential.revision_created = $filter('date')(_revision.created * 1000 , "dd-MM-yyyy @ HH:mm:ss"); + CredentialService.updateCredential(_credential, (key)).then(function (result) { SettingsService.setSetting('revision_credential', null); $rootScope.$emit('app_menu', false); $location.path('/vault/' + $routeParams.vault_id);