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

Multiple auth providers and dingo #1767

Open
prasanthsd opened this issue Jan 5, 2021 · 1 comment
Open

Multiple auth providers and dingo #1767

prasanthsd opened this issue Jan 5, 2021 · 1 comment

Comments

@prasanthsd
Copy link

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 8.x
Package version 3.x.x
PHP version

Actual Behaviour

I have created multiple guards and providers in auth.php. I have User model and AdminUser model. I can actually login and generate JWT token in both cases. But then problem is in my auth middleware where I try to check if the user is authenticated. The below code (It resides inside a middleware) always checks the default Users model and not the admin users model. Is there any way to fix it?

$this->auth->authenticate($route->getAuthenticationProviders());

@specialtactics
Copy link
Member

Hi

I don't overly understand your issue (in particular the user model vs admin model), but the way dingo authentication works is it just goes down the list of authentication providers until one authenticates, and if none do, then it considers the request unauthenticated.

You should also read this, as you should be using dingo auth, not laravel auth (which you might be)
https://github.com/dingo/api/wiki/Authentication

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

2 participants