Fix social post voter

pull/4161/head
Angel Fernando Quiroz Campos 3 years ago
parent c28a900cae
commit 9b3181923c
  1. 10
      src/CoreBundle/Security/Authorization/Voter/SocialPostVoter.php

@ -68,11 +68,15 @@ class SocialPostVoter extends Voter
/** @var SocialPost $post */ /** @var SocialPost $post */
$post = $subject; $post = $subject;
$sender = $post->getSender(); $sender = $post->getSender();
$userReceiver = $post->getUserReceiver();
switch ($attribute) { switch ($attribute) {
case self::CREATE: case self::CREATE:
if ($currentUser->hasFriendWithRelationType($sender, UserRelUser::USER_RELATION_TYPE_FRIEND)) { if (
return true; $userReceiver &&
!$sender->hasFriendWithRelationType($userReceiver, UserRelUser::USER_RELATION_TYPE_FRIEND)
) {
return false;
} }
// no break // no break
case self::EDIT: case self::EDIT:
@ -86,6 +90,6 @@ class SocialPostVoter extends Voter
return true; return true;
} }
return true; return false;
} }
} }

Loading…
Cancel
Save