Open erdem opened 5 months ago
I couldn't create a pull request for the issue due to limited time but it seems like built-in AuthenticationFailed exception class has an inheritance order issue.
AuthenticationFailed
https://github.com/eadwinCode/django-ninja-jwt/blob/master/ninja_jwt/exceptions.py#L35
This class doesn't get default_code attribute from AuthenticationFailed exception, instead it gets from DetailDictMixin class which is empty string.
default_code
DetailDictMixin
my implementation:
@api_controller("/auth", tags=["auth"]) class UserTokenController(TokenObtainSlidingController): auto_import = True @route.post("/login", response=UserTokenOutSchema, url_name="login") def obtain_token(self, user_token: jwt_schemas.TokenObtainSlidingInputSchema): user = user_token._user token = SlidingToken.for_user(user) return UserTokenOutSchema( user=user, token=str(token), token_exp_date=datetime.fromtimestamp(token["exp"], tz=timezone.utc), )
{ "detail": "No active account found with the given credentials", "code": "" }
Thanks
I couldn't create a pull request for the issue due to limited time but it seems like built-in
AuthenticationFailed
exception class has an inheritance order issue.https://github.com/eadwinCode/django-ninja-jwt/blob/master/ninja_jwt/exceptions.py#L35
This class doesn't get
default_code
attribute fromAuthenticationFailed
exception, instead it gets fromDetailDictMixin
class which is empty string.my implementation:
Thanks