JosephSilber / bouncer

Laravel Eloquent roles and abilities.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disallow Everyone not working as expected

undjike opened this issue · comments

Hello, I have this code...

$user = User::factory()->create();

Auth::login($user);

Bouncer::allow($user)->to('delete-entity', $entity);

$firstTest = Bouncer::can('delete-entity', $entity);

Bouncer::disallowEveryone()->to('delete-entity', $entity);

Bouncer::refreshFor($user);
Bouncer::refresh();

$secondTest = Bouncer::can('delete-entity', $entity);

The output is :

$firstTest = true
$secondTest = true

Expected behaviour :

$firstTest = true
$secondTest = false

Can anyone help?

The "everyone" ability is a broader ability than the ability granted directly to a user. The disallowEveryone method simply removes a general ability that was previously granted via allowEveryone.