mirror of
https://github.com/flarum/core.git
synced 2025-10-12 23:44:27 +02:00
Policy Extender and Tests (#2461)
Policy application has also been refactored, so that policies return one of `allow`, `deny`, `forceAllow`, `forceDeny`. The result of a set of policies is no longer the first non-null result, but rather the highest priority result (forceDeny > forceAllow > deny > allow, so if a single forceDeny is present, that beats out all other returned results). This removes order in which extensions boot as a factor.
This commit is contained in:
committed by
GitHub
parent
8901073d12
commit
d1dfa758e4
@@ -7,18 +7,13 @@
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Group;
|
||||
namespace Flarum\Group\Access;
|
||||
|
||||
use Flarum\User\AbstractPolicy;
|
||||
use Flarum\User\Access\AbstractPolicy;
|
||||
use Flarum\User\User;
|
||||
|
||||
class GroupPolicy extends AbstractPolicy
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $model = Group::class;
|
||||
|
||||
/**
|
||||
* @param User $actor
|
||||
* @param string $ability
|
||||
@@ -27,7 +22,7 @@ class GroupPolicy extends AbstractPolicy
|
||||
public function can(User $actor, $ability)
|
||||
{
|
||||
if ($actor->hasPermission('group.'.$ability)) {
|
||||
return true;
|
||||
return $this->allow();
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,9 +19,6 @@ class GroupServiceProvider extends AbstractServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$events = $this->app->make('events');
|
||||
$events->subscribe(GroupPolicy::class);
|
||||
|
||||
Group::registerVisibilityScoper(new ScopeGroupVisibility(), 'view');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user