Docs: Add guard example to JWT docs #3189
Labels
Documentation 📚
This is related to documentation
Good First Issue
This is good for newcomers to take on
Help Wanted 🆘
This is good for people to work on
Summary
Currently in the JWT docs there are a few references regarding how to access the 'User' object during and after being authenticated. These boil down to:
a) queried using the token
b) directly from the request (which can be easily assumed to be attached via retrieve_user_handler prior to going to the api path)
However there are other instances where user details need to be extracted from the
connection
object (such as in role-based guards).A gap in knowledge between the page on JWTs and guards is that it's not made entirely clear how user gets attached to connection. I would like to suggest that an example guard is added to the JWT docs with a comment explaining that the Auth object automatically attaches it for you based on the object returned from
retrieve_user_handler
.It also isn't made abundantly clear that the TypeVar provided to the Auth object directly corresponds to the retrieve_user_handler. For a little while, I was actually setting the TypeVar based on my login response and wondering why it wasn't working. A silly mistake in hindsight, but I believe a simple comment could have saved me from it!
Note
While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.
Check out all issues funded or available for funding on our Polar.sh dashboard
The text was updated successfully, but these errors were encountered: