Open old-joker opened 2 years ago
Does the is_active callable work? If not, you'll need to subclass the authentication class
i'm new in django , can you help me how can i check this ?
I think you must override TokenObtainSerializer
Example:
#serializers.py
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
class CustomTokenObtainPairSerializer(TokenObtainPairSerializer):
default_error_messages = {
'no_active_account': 'Username or Password does not matched.' # here you pass the message
}
# views.py
from rest_framework_simplejwt.views import TokenObtainPairView
from . serializers import CustomTokenObtainSerializer
class CustomTokenObtainPairView(TokenObtainPairView):
serializer_class = CustomTokenObtainPairSerializer
#urls.py
from . views import CustomTokenObtainPairView
urlpatterns = [
...
path('token/', CustomTokenObtainPairView.as_view(), name='token_obtain_pair'),
...
]
I am using Django 4.0 and Djoser 2.1.0 but when trying to get JWT token for an inactive user, it returns the same error as using a wrong password which makes it tricky to differentiate. I get HTTP STATUS 401 with the detail below
{ "detail": "No active account found with the given credentials }
how can i change it to check user activation status and not registered user or add some feature to set check activation status of users