-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
500 internal server error when retrieve_user returns None #199
Comments
retrieve_user
returns None
What is the expected response? You can always catch that and provide a response yourself. |
@ahopkins I would say |
I am thinking maybe Regardless, you can catch exceptions like this: @app.exception(InvalidRetrieveUserObject)
async def invalid_user(request, exception):
return text("Looks like we got another bad user... 😒") https://sanic.readthedocs.io/en/latest/sanic/exceptions.html#handling-exceptions |
Having the same issue here. @ahopkins is there any other way to handle deleted users? |
What do you have in mind? Also, not to be one to tell you how to structure your app, but in my experience typically you do not want to delete user records, but instead deactivate them. Does the above exception handler not work for you? |
Maybe deactivating the user instead is the way to go. But also it would be nice if sanic-jwt supported removing users. At first this solution was not working for me since the exception was handled by this function that handles the exception and returns an 500 error: But I got it working by adding the exception handler before calling the |
The "problem" with that solution is that sanic-jwt is not meant to get involved in how your application handles users. All it should need to know is how to get them, because anything else would be highly domain specific. |
Yeah that makes sense. But there should be a way to use sanic-jwt so that one can delete users. And there should be a documented way to implement that. It seems reasonable to me that the correct way to implement that using sanic-jwt would be to make it so that the On somewhat related note: This issue was really hard to debug since sanic-jwt seems to hide the error and just return an 500 error. This issue of debugging being hard happened to me a few times actually when my ** I did not check how the disabled user use case would work. I guess retrieve_user would return the user data but what would then handle that the refresh endpoint does not then return a new token? Should it be handled in the |
I am not clear if you are looking for another way to catch the |
As seen here:
sanic-jwt/sanic_jwt/authentication.py
Line 43 in a6fcb7f
user
isNone
,BaseAuthentication
raisesInvalidRetrieveUserObject
. In my case when a/auth/refresh
request arrives with a token created for a user not present, this problem happens.The text was updated successfully, but these errors were encountered: