Skip to content
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

Wrong value of config('auth.defaults.guard') when you're logged with another guard. #22096

Closed
willypuzzle opened this issue Nov 16, 2017 · 7 comments

Comments

@willypuzzle
Copy link
Contributor

  • Laravel Version: 5.5.21
  • PHP Version: 7.1.11
  • Database Driver & Version: mysql 7.1.11

Description:

When I'm logged with another guard than the default guard and I try to get the default guard value with config('auth.defaults.guard') it returns the current guard value (the guard which I'm currently logged in) rather than the real default guard value.

For example, if I have two guards 'web' and 'admin' and the default guard is 'web' and I'm logged with 'admin' when I make config('auth.defaults.guard') it returns 'admin'.

Steps To Reproduce:

Try to get the default guard value with config function when you're logged with another guard.

@willypuzzle willypuzzle changed the title Error value of config('auth.defaults.guard') when you're logged with another guard. Wrong value of config('auth.defaults.guard') when you're logged with another guard. Nov 17, 2017
@themsaid
Copy link
Member

themsaid commented Nov 22, 2017

Yes laravel switches the default driver used to the current used guard.

@willypuzzle
Copy link
Contributor Author

I think that when I call the config function it returns the config value.

@GabrielaSaldana
Copy link

Hello, I don't much about guards but I have followed this steps for a web and admin guards and it works perfectly for me, maybe you are missing the configuration of some Laravel Files, checkout this video : https://www.youtube.com/watch?v=iKRLrJXNN4M

@driesvints
Copy link
Member

This is expected behavior. Laravel will switch the default guard to the current one used.

@willypuzzle
Copy link
Contributor Author

How Do I suppose to get the default guard if I'm logged with another guard?

@MladenJanjetovic
Copy link

This is expected behavior. Laravel will switch the default guard to the current one used.

I don't see how this is expected behaviour. It's confusing.
Default should be default auth guard as per config file, no matter what is the current ACTIVE guard on the route.

@DevBodin
Copy link

DevBodin commented Aug 3, 2022

Definitely going to need a better explanation here. Honestly baffled it's been closed.

  1. "Default" does not mean "current,"
  2. If you manually set a config value, that's the value expect to be returned.
  3. This very predictably leads to the obvious question: "How do I find the actual default value?"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants