Shouldn't it be the inverse?
Its causing a problem where I have 'auth.defaults.guard' set to api but getDefaultGuardName() returns web because its first on the list of getGuardNames()
was going to make a PR but it broke a bunch of tests
Ya, switching it to the inverse also won't get the desired results.
getDefaultGuardName() is invoked (directly or indirectly) by pretty much all of the Permission-related functions, ie: hasPermissionTo, givePermissionTo, revokePermissionTo, and by scopes like scopePermission and scopeRole.
Fortunately or unfortunately that means changing that code will affect everything.
Pinging @AlexVanderbist for input ...
When getting the default guard name using getDefaultGuardName I assumed the following order:
guard_name on the model use that as the default guard nameauth.defaults.guard nameI agree that when getGuardNames() returns the default auth.defaults.guard as one of the guard names it should probably use that as the default (instead of the first one). However I can't think of a way to implement this without making breaking changes...
I'd suggest using different models for every guard for the time being. This can easily be accomplished by extending the User model in an ApiUser class or something similar.
Got it, thank you guys
This should be documented, I just spent hour debugging why I get web guard instead of api...
Line from the docs (quoted below) is lie misleading:
By default the default guard (config('auth.defaults.guard')) will be used as the guard for new permissions and roles.
@Kyslik thanks for pointing this out. Feel free to PR a change to the docs and we'll merge it in
@AlexVanderbist hey, I am non-native english speaker, and I can not imagine formulating a good sentence. Will this do?
By default the default guard is a guard which is first defined in
auth.guardsconfig array.
馃槅 three times guard term is used, sure its confusing...
@AlexVanderbist wow, I fixed it, Thank you so much <3
This is still not documented I think.
Most helpful comment
This should be documented, I just spent hour debugging why I get
webguard instead ofapi...Line from the docs (quoted below) is
liemisleading: