-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Cannot use multiple guards #2794
Comments
Maybe related #2729 (comment) |
@parallels999 not related to my issue. That post talks about the wrong default guard. In my case, the correct default guard is being used, but I am having trouble assigning a role to a new user because that role uses another guard (not the default one). |
So, you could add a default unique guard for everything, Would that solve your problem? |
@parallels999 I need 2 guards as I have web and mobile app users. The 'web' guard is not typically used for mobile apps. |
It seems that you did not understand correctly I'm not saying that you delete guards in Laravel, I'm saying that you use a default guard_name in Laravel permission, so you can reuse the same roles/permissions in any Laravel guard |
@parallels999 ok so I can use the same guard_name for all roles/permissions, but I can keep using different guards for web and app users in Laravel? |
|
This is a workaround but its fine with me. I will leave this open meanwhile. |
Description
I have a controller where I create users. I currently have 2 guards: 'web' and 'mobile'. When creating users with guard_name in roles/permissions as 'web' it works fine because the Spatie functions such as syncRoles and assignRole use 'web' by default. But how do I force it to use 'mobile' guard name when the user role is 'app-user' ?
Note: I am not talking about the authentication part, only the user creation.
I marked this as a bug because the package doc states that it does support multiple guard names for roles but doesn't seem to support it.
My auth.php configs:
and the User model:
Error:
Steps To Reproduce
...
Example Application
No response
Version of spatie/laravel-permission package:
^6.10
Version of laravel/framework package:
^11.0
PHP version:
8.3.15
Database engine and version:
No response
OS: Windows/Mac/Linux version:
Ubuntu 22.04.5 LTS
The text was updated successfully, but these errors were encountered: