19.6 Putting It All Together
This chapter is the tip of the iceberg when it comes to auth. We learned about sessions and cookies, took a quick look at some of the tools provided by the auth app, and then built two very straightforward webpages.
The User model is the heart of the auth app, and while we did not interact with it directly, both the login() and logout() views are manipulating the user data sent as part of the HttpRequest object. The views will receive either a User or an AnonymousUser.
When login() receives the POST data from AuthenticationForm, it finds a user by the same username and then uses the check_password() method provided by the User class. In the event the password matches the hash stored in the database, then the login() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access