Don't allow guests to alter subscription

This commit is contained in:
Toby Zerner 2015-09-03 15:42:12 +09:30
parent 74fdf7b79c
commit 98369acd70

View File

@ -1,6 +1,7 @@
<?php namespace Flarum\Subscriptions\Listeners;
use Flarum\Events\DiscussionWillBeSaved;
use Flarum\Core\Exceptions\PermissionDeniedException;
class PersistSubscriptionData
{
@ -18,6 +19,10 @@ class PersistSubscriptionData
$actor = $event->actor;
$subscription = $data['attributes']['subscription'];
if (! $actor->exists) {
throw new PermissionDeniedException;
}
$state = $discussion->stateFor($actor);
if (! in_array($subscription, ['follow', 'ignore'])) {