Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve permissions inheritance based on roles issue #169

Open
wants to merge 3 commits into
base: 1.0
Choose a base branch
from

Conversation

QuentinPetel
Copy link

@QuentinPetel QuentinPetel commented Nov 15, 2016

See #168

@QuentinPetel
Copy link
Author

QuentinPetel commented Nov 16, 2016

If you're using the laravel cache, do php artisan cache:clear to have it work.
Edit: Cache::forget() added when assign/revoke Role/Permission

…erride role ones + cache delete on assign/revoke role/permissions
@kodeine
Copy link
Owner

kodeine commented Dec 8, 2016

@QuentinPetel can you please resolve the conflicts so i can merge this?

Thanks

@QuentinPetel
Copy link
Author

Done.

One thing however still not fixed. If you already have an $user loaded, you have to ::find this user again to avoid getting roles or permissions outdated.

Something like :
$user->assignRole('slug_role');
$user = User::find($user->id);

@pimlie
Copy link

pimlie commented May 18, 2017

Something like :
$user->assignRole('slug_role');
$user = User::find($user->id);

Just a few days ago a refresh method has been added to Model (bot not yet released). So you could use $this->refresh(); within assignRole now. For older versions you could implement the refresh yourself.

if (version_compare(App::version(), '5.4.24', '>=')) { // Version number is a guess
    $this->refresh();
} else {
    if (! $this->exists) {
        return;
    }
    $this->load(array_keys($this->relations));
    $this->setRawAttributes(static::findOrFail($this->getKey())->attributes);
}

Repository owner deleted a comment from Messhias Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants