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
Include request.auth
or request.auth.credentials
in default view template context
#2419
Comments
Why dont you use I use something like below;
|
I'm conflicted about exposing security information to every default context. Also, credentials alone are not enough as you can have credentials and the user is not authenticated (e.g. expired cookie with |
Ok thanks @hueniverse for the explanation. And thanks @ubaltaci for the |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
I think it would be useful to have
request.auth.credentials
be included in the default template context.Here's my reasoning for that:
For pretty much any website that has a login feature, parts of the page will be rendered conditionally based on the current user's state. Perhaps it will display their username in the header and show a logout button for logged-in users.
I usually build my sites out at first without any auth and then add auth at a later stage. If I'm using a common layout, I would later need to add something like the following to the handler of every route.
And in my template I might have something like:
The time and extra clutter in handlers could be saved by including
request.auth.credentials
in the default template context.The text was updated successfully, but these errors were encountered: