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

[5.8] Fix guessed policy names when using Gate::forUser #27708

Merged
merged 2 commits into from
Feb 28, 2019

Conversation

erikgaal
Copy link
Contributor

Overview

When using the Gate facade to create a new instance for a specific user with forUser the guessPolicyNameUsingCallback is not passed on to the new instance. This results in the policies no policies being loaded when using just the policy name guesser.

Reproduction

Gate::guessPolicyNamesUsing(function ($class) {
    return 'foo';
});

dump(app(Gate::class));
// #guessPolicyNamesUsingCallback: Closure($class) {#371

dump(app(Gate::class)->forUser($user));
// #guessPolicyNamesUsingCallback: null

Proposed Solution

Add the guessPolicyNameUsingCallback nullable argument to the constructor and pass it in the forUser method.

@erikgaal
Copy link
Contributor Author

This probably needs a test so it won't break again.

@erikgaal erikgaal changed the title [5.8] Make Gate::forUser pass the policy guesser to the constructor [5.8] Fix guessed policy names when using Gate::forUser Feb 28, 2019
@taylorotwell taylorotwell merged commit c56c597 into laravel:5.8 Feb 28, 2019
@erikgaal erikgaal deleted the 5.8-gate-for-user-policy-guesser branch February 28, 2019 13:53
@TBlindaruk
Copy link
Contributor

@erikgaal #27757 I have created issue for the test

taylorotwell added a commit that referenced this pull request Mar 4, 2019
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