Skip to content

Wrong database when checking permissions #2699

Answered by krand-dsa
krand-dsa asked this question in Q&A
Discussion options

You must be logged in to vote

Problem:
laravel-multitenancy supports to have separate databases for the landlord and each of the tenants. It also provides tasks that can be run when switching to/from a tenant in order to set the database connection and other configs as needed. In my case the database switching was done correctly and the User model was aware which database connection (the tenant one) to use. This is done by using the UsesTenantConnection trait.
The User model also uses the HasRoles trait of laravel-permission, which itself uses the HasPermissions trait. HasPermissions provides the hasPermissionTo function, which is used to check if a user has a certain permission. The inner workings of this function ig…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@krand-dsa
Comment options

@drbyte
Comment options

Comment options

You must be logged in to vote
1 reply
@krand-dsa
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by krand-dsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants