Fix owner's shared key being gone when bob updates credential

This commit is contained in:
Marcos Zuriaga 2016-10-03 21:43:57 +02:00
parent 653fd9bace
commit bec9252bc9
No known key found for this signature in database
GPG key ID: 7D15585354D072FF

View file

@ -127,14 +127,17 @@ class CredentialController extends ApiController {
'delete_time' => $delete_time,
'hidden' => $hidden,
'otp' => $otp,
'shared_key' => ($shared_key === null) ? null : $storedCredential->getSharedKey(),
'shared_key' => $shared_key,
);
if ($storedCredential->getUserId() !== $this->userId){
$acl = $this->sharingService->getCredentialAclForUser($this->userId, $storedCredential->getGuid());
if (!$acl->hasPermission(SharingACL::WRITE)){
if ($acl->hasPermission(SharingACL::WRITE)) {
$credential['shared_key'] = $storedCredential->getSharedKey();
}
else {
return new DataResponse(['msg' => 'Not authorized'], Http::STATUS_UNAUTHORIZED);
}
}