Package utilization currently extremelly confusing when using Laravel Sanctum #2106
edsonfeimberg
started this conversation in
General
Replies: 2 comments
-
I don't work with sanctum, maybe 'defaults' => [
'guard' => 'sanctum',
'passwords' => 'users',
],
'guards' => [
'sanctum' => [
'driver' => 'sanctum',
'provider' => 'users',
],
'web' => [
'driver' => 'session',
'provider' => 'users',
],
], |
Beta Was this translation helpful? Give feedback.
0 replies
-
Feel free to make a PR for better documentation |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have the impression that somethings should be a bit clearer for users using Laravel Sanctum. The origin of the biggest problems is this:
"If your app uses only a single guard, but is not web (Laravel's default, which shows "first" in the auth config file) then change the order of your listed guards in your config/auth.php to list your primary guard as the default and as the first in the list of defined guards. While you're editing that file, best to remove any guards you don't use, too."
Now, a Laravel Sanctum users should have something like this in config/auth:
The problem is that we can't make changes to this 'web' key in guards[] array, because Sanctum works on top of it. So problems arrive. For example, when trying to create a simple UserSeeder with a role of 'Super Admin' like this:
We will get errors like:
Am i missing something or the only current solution would be to always pass a
'guard_name' => 'web'
argument whenever creating new roles? Would manually setting'guard_name' => 'web'
event grant the perfect function of the package since the default guard would be actually sanctum? Anyway, i have the impression that things could be a bit better explained to Sanctum users, since it is becoming kind of a default for Laravel Api development.Beta Was this translation helpful? Give feedback.
All reactions