mirror of
https://github.com/flarum/framework.git
synced 2024-11-27 02:53:37 +08:00
Remove AssertPermissionTrait (#26)
* Remove AssertPermissionTrait * Apply fixes from StyleCI * Fix my dumb mistake * Fix another small mistake ->assertRegistered Co-authored-by: luceos <daniel+github@klabbers.email>
This commit is contained in:
parent
5d64996b84
commit
e85063fbf7
|
@ -12,14 +12,11 @@ namespace Flarum\Flags\Api\Controller;
|
|||
use Flarum\Api\Controller\AbstractListController;
|
||||
use Flarum\Flags\Api\Serializer\FlagSerializer;
|
||||
use Flarum\Flags\Flag;
|
||||
use Flarum\User\AssertPermissionTrait;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Tobscure\JsonApi\Document;
|
||||
|
||||
class ListFlagsController extends AbstractListController
|
||||
{
|
||||
use AssertPermissionTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -42,7 +39,7 @@ class ListFlagsController extends AbstractListController
|
|||
{
|
||||
$actor = $request->getAttribute('actor');
|
||||
|
||||
$this->assertRegistered($actor);
|
||||
$actor->assertRegistered();
|
||||
|
||||
$actor->read_flags_at = time();
|
||||
$actor->save();
|
||||
|
|
|
@ -14,15 +14,12 @@ use Flarum\Foundation\ValidationException;
|
|||
use Flarum\Post\CommentPost;
|
||||
use Flarum\Post\PostRepository;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\User\AssertPermissionTrait;
|
||||
use Flarum\User\Exception\PermissionDeniedException;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Tobscure\JsonApi\Exception\InvalidParameterException;
|
||||
|
||||
class CreateFlagHandler
|
||||
{
|
||||
use AssertPermissionTrait;
|
||||
|
||||
/**
|
||||
* @var PostRepository
|
||||
*/
|
||||
|
@ -67,7 +64,7 @@ class CreateFlagHandler
|
|||
throw new InvalidParameterException;
|
||||
}
|
||||
|
||||
$this->assertCan($actor, 'flag', $post);
|
||||
$actor->assertCan('flag', $post);
|
||||
|
||||
if ($actor->id === $post->user_id && ! $this->settings->get('flarum-flags.can_flag_own')) {
|
||||
throw new PermissionDeniedException();
|
||||
|
|
|
@ -12,13 +12,10 @@ namespace Flarum\Flags\Command;
|
|||
use Flarum\Flags\Event\FlagsWillBeDeleted;
|
||||
use Flarum\Flags\Flag;
|
||||
use Flarum\Post\PostRepository;
|
||||
use Flarum\User\AssertPermissionTrait;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class DeleteFlagsHandler
|
||||
{
|
||||
use AssertPermissionTrait;
|
||||
|
||||
/**
|
||||
* @var PostRepository
|
||||
*/
|
||||
|
@ -49,7 +46,7 @@ class DeleteFlagsHandler
|
|||
|
||||
$post = $this->posts->findOrFail($command->postId, $actor);
|
||||
|
||||
$this->assertCan($actor, 'viewFlags', $post->discussion);
|
||||
$actor->assertCan('viewFlags', $post->discussion);
|
||||
|
||||
$this->events->dispatch(new FlagsWillBeDeleted($post, $actor, $command->data));
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user