Skip to content

Commit

Permalink
Use AssertPermissionTrait instead of $actor->can in backported fix (#97)
Browse files Browse the repository at this point in the history
$actor->can was introduced in beta 14, and is not yet available.
  • Loading branch information
askvortsov1 authored Oct 6, 2020
1 parent cd97f4e commit f929d10
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Listener/SaveTagsToDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\Tags\Event\DiscussionWasTagged;
use Flarum\Tags\Tag;
use Flarum\User\AssertPermissionTrait;
use Flarum\User\Exception\PermissionDeniedException;
use Illuminate\Contracts\Validation\Factory;
use Symfony\Component\Translation\TranslatorInterface;

class SaveTagsToDatabase
{
use AssertPermissionTrait;

/**
* @var SettingsRepositoryInterface
*/
Expand Down Expand Up @@ -60,7 +63,7 @@ public function handle(Saving $event)
// TODO: clean up, prevent discussion from being created without tags
if (isset($event->data['relationships']['tags']['data'])) {
if ($discussion->exists) {
$actor->assertCan('tag', $discussion);
$this->assertCan($actor, 'tag', $discussion);
}

$linkage = (array) $event->data['relationships']['tags']['data'];
Expand Down

0 comments on commit f929d10

Please sign in to comment.