-
Notifications
You must be signed in to change notification settings - Fork 673
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
how to change the database table used by simplejwt to authenticate user for generating token instead of using auth_user table? #359
Comments
I don't think SimpleJWT offers any user model that isn't specified with |
Then what if we have some another Model like Employee or Customer where we are managing email and password by our own?? |
@yash0307jain Did you find any solution? |
@yash0307jain @deepanshu-nickelfox SimpleJWT is not an extensible framework; it was decided awhile ago it's a solution and not really something to extend. What you could do is go to https://github.com/SimpleJWT/django-rest-framework-simplejwt/blob/c684e8396f8446cc289ed73a0740ca222c85470d/rest_framework_simplejwt/authentication.py#L28 (authentication.py) and change the designated model. You would also need to reconfigure some other places like the default login rule and such. |
I got the solution the owner already has added this feature... |
Also, @Andrew-Chen-Wang , do i need to reset my token model can you please tell me Why?? |
tl;dr Don't worry; that correct. You can make sure via Probably not if you're referring to models.py. I believe TokenUser is only used for the other authentication type, but you're using the default which simply grabs the correct Django model. Every time you authenticate and DRF calls |
Nope Nothing happend: i am getting same error as Field 'id' expected a number but got '377f9e30-9eea-4cf1-a0c3-7bd969184f25'. Also, the request.user is AnonymousUser also, i have created a new db, but nothing happend. |
|
This is what i am doing: `from rest_framework_simplejwt.authentication import JWTAuthentication class CustomJWTAuthentication(JWTAuthentication): also, i have override that settings
but i am not aware of your 3rd point sir |
So like I said in Point 2, you didn't follow what I was saying. So you've overriden the class; now you need to override the |
yeah man, i really tried first by extending the :
i check user_class it is same as my model, but it still showing error...... after some time i found there is another user model in state.py any simple method to use our own model?? |
if you can share any snip done by you, it could be a really be a great help |
You could also just set your model with AUTH_USER_MODEL in your settings so you don't have to go through all this trouble. Regarding is_active, in the settings you can change the login rule option to your own custom rule. So again, re-read what I wrote here: #359 (comment) |
yeah i got it, i can't change my user model in middle of the project with some AUTH_USER_MODEL, is there any other library, which i can use, see i am new to python and django so, i don't know about all these. |
btw Thank you so much Mr. @Andrew-Chen-Wang for your help, you are such a great person |
I see. This library isn't meant to be extensible. Would I'd do is just override lots of the classes to suit my needs. There should be some Django OAuth library that could probably help. I think it's run by Jazzband, and typically their packages are extensible. |
👍 |
Closing since this is the right answer:
|
I couldn't find the configuration to use some specific table to generate the token instead of auth_user table
The text was updated successfully, but these errors were encountered: