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

Please allow different user types using different models for authentication #9598

Open
2 of 6 tasks
MuhammadWaqarAnwar opened this issue Dec 3, 2024 · 2 comments
Open
2 of 6 tasks

Comments

@MuhammadWaqarAnwar
Copy link

MuhammadWaqarAnwar commented Dec 3, 2024

Checklist

  • Raised initially as discussion #...
  • This is not a feature request suitable for implementation outside this project. Please elaborate what it is:
    • compatibility fix for new Django/Python version ...
    • other type of bug fix
    • other type of improvement
  • I have reduced the issue to the simplest possible case.

i have made different JWT authentications for different user models (admin and simple user). But the problem is that in settings.py the AUTH_USER_MODEL can only allow one user authentication.
Hence the problem appears where if i authenticate in admin section from admin credentials, then it doesn't allow and says invalid credentials. but if i authenticate in admin section from normal user credentials then it is allowed. because in settings.py the AUTH_USER_MODEL equals to users.User and not the other Admin User. please develop this new feature where we are allowed to have more than 1 AUTH_USER_MODELS in settings.py

@NikitaJaiswal77
Copy link

NikitaJaiswal77 commented Dec 9, 2024

please assign this to me , i want to work on this @MuhammadWaqarAnwar

@d3corator
Copy link

@MuhammadWaqarAnwar This is not a DRF limitation but a Django restriction. Django’s AUTH_USER_MODEL can only point to one user model, as it’s deeply integrated with the authentication system. To support multiple user models, you can use custom authentication backends or handle different user types (e.g., admin vs. regular users) within a single model or via separate views.
This could help: https://stackoverflow.com/a/65842734/5082800

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

3 participants