Skip to content

Use Authorizable in GateCollector #735

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

Merged
merged 1 commit into from
Dec 24, 2017
Merged

Conversation

devinfd
Copy link
Contributor

@devinfd devinfd commented Oct 8, 2017

addCheck assumed that the authorized model was the authenticated App\User. In my case I have a App\User, App\Account and an App\AccountUser. The App\User is authenticated but authorizations are on the App\AccountUser which does not implement Authenticatable.

This change type hints $user to Authorizable because thats what is actually relevant in this collector. It also uses the Authorizable's base class name in the message instead of assuming 'user'.

addCheck assumed that the authorized model was the authenticated App\User. In my case I have a App\User, App\Account and an App\AccountUser. The App\User is authenticated but authorizations are on the App\AccountUser which does not implement Authenticatable.

This change type hints $user to Authorizable because thats what is really important in this collector. It also uses the Authorizable's base class name in the message instead of assuming user.
@devinfd devinfd changed the title Update GateCollector Use Authorizable in GateCollector Oct 18, 2017
@jesseschutt
Copy link

I'm in the same boat here. I'm applying authorizations to a non-authenticable model which is breaking the gate collector. The proposed pull-request fixes the issue for me.

@devinfd
Copy link
Contributor Author

devinfd commented Nov 24, 2017

Ping. This is becoming an issue for my team. We can not composed update without this change.

@jesseschutt
Copy link

Just checking in to see if this might be approved at some point?

@barryvdh
Copy link
Owner

Is this supported in all recent versions of Laravel?

@barryvdh
Copy link
Owner

Do we need the typehint?

@devinfd
Copy link
Contributor Author

devinfd commented Dec 23, 2017

Illuminate\Contracts\Auth\Access\Authorizable is the correct namespace all the way back to laravel 5.1.

I don't really see that the type hint is needed except that you had one originally and this PR is just following that pattern. The typehint could be simplified to just Model only because of the $user->id

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