You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue:
We have routes with model/route binding like posts/{post:slug}. Also posts have a global scope that checks if the user's role exists and is one of x. All routes have middleware that checks if a users has access to the route and we have middleware that sets the permissions team id (setPermissionTeamId). However, when a post:slug is clicked, the rout/model binding takes place before all middleware is executed. So, at this point the user object exists, but does not have any role or permission attached.
The only way to overcome this is to use the setPermissionsTeamId in the global scope, which feels quite clumsy and not the way we would like to fix this.
question:
Is there a way to add the setPermissionTeamsId just before the route/model binding is executed, so the roles/permissions are available on the user object? An we do not have to add this one simple line to each global scope?
Tanks in advance.
I found another discussion about global scopes, but it did not really give me an answer to this issue.
As I mentioned in my issue, setting the middleware does nothing for the route/model binding. We have tested with the middleware suggested in the documentation without any success.
At this point I've created an event listener on the Authenticated class and then execute the setPermissionsTeamId. That works, for now.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Issue:
We have routes with model/route binding like posts/{post:slug}. Also posts have a global scope that checks if the user's role exists and is one of x. All routes have middleware that checks if a users has access to the route and we have middleware that sets the permissions team id (setPermissionTeamId). However, when a post:slug is clicked, the rout/model binding takes place before all middleware is executed. So, at this point the user object exists, but does not have any role or permission attached.
The only way to overcome this is to use the setPermissionsTeamId in the global scope, which feels quite clumsy and not the way we would like to fix this.
question:
Is there a way to add the setPermissionTeamsId just before the route/model binding is executed, so the roles/permissions are available on the user object? An we do not have to add this one simple line to each global scope?
Tanks in advance.
I found another discussion about global scopes, but it did not really give me an answer to this issue.
Beta Was this translation helpful? Give feedback.
All reactions