JosephSilber / bouncer

Laravel Eloquent roles and abilities.
MIT License
3.45k stars 332 forks source link

Remove all roles or abilities for a user #563

Closed cjaoude closed 2 years ago

cjaoude commented 3 years ago

It's be nice to reset a user...

Bouncer::reset($user); // removes all roles, abilities...
Bouncer::reset($user, 'default'); // removes all roles, abilities...with a 'safe' default we can specify
Bouncer::disavow($user); // alias  ;-)

Bouncer::disallow($user)->to('*'); // removes all abilities
Bouncer::disallow($user)->to('*'); // removes all abilities

Bouncer::retract('*')->from($user); // removes all roles
$user->retract('*'); // removes all roles
Bouncer::retract($user)
JosephSilber commented 3 years ago

You can currently do this with these 3 commands:

Bouncer::sync($user)->roles([]);
Bouncer::sync($user)->abilities([]);
Bouncer::sync($user)->forbiddenAbilities([]);