Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #834: Added documentation of the built-in authentication views.…

… Thanks, Ubernostrum.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4627 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b581d732227c9d347c4046a66879d8c4c9c6cec5 1 parent b21fd1e
Jacob Kaplan-Moss authored February 26, 2007

Showing 1 changed file with 151 additions and 0 deletions. Show diff stats Hide diff stats

  1. 151  docs/authentication.txt
151  docs/authentication.txt
@@ -317,6 +317,16 @@ This example shows how you might use both ``authenticate()`` and ``login()``::
317 317
         else:
318 318
             # Return an 'invalid login' error message.
319 319
 
  320
+Manually checking a user's password
  321
+-----------------------------------
  322
+
  323
+If you'd like to manually authenticate a user by comparing a
  324
+plain-text password to the hashed password in the database, use the
  325
+convenience function `django.contrib.auth.models.check_password`. It
  326
+takes two arguments: the plain-text password to check, and the full
  327
+value of a user's ``password`` field in the database to check against,
  328
+and returns ``True`` if they match, ``False`` otherwise.
  329
+
320 330
 How to log a user out
321 331
 ---------------------
322 332
 
@@ -444,6 +454,147 @@ block::
444 454
 .. _forms documentation: ../forms/
445 455
 .. _site framework docs: ../sites/
446 456
 
  457
+Other built-in views
  458
+--------------------
  459
+
  460
+In addition to the `login` view, the authentication system includes a
  461
+few other useful built-in views:
  462
+
  463
+``django.contrib.auth.views.logout``
  464
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  465
+
  466
+**Description:**
  467
+
  468
+Logs a user out.
  469
+
  470
+**Optional arguments:**
  471
+
  472
+    * ``template_name``: The full name of a template to display after
  473
+      logging the user out. This will default to
  474
+      ``registration/logged_out.html`` if no argument is supplied.
  475
+
  476
+**Template context:**
  477
+
  478
+    * ``title``: The string "Logged out", localized.
  479
+
  480
+``django.contrib.auth.views.logout_then_login``
  481
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  482
+
  483
+**Description:**
  484
+
  485
+Logs a user out, then redirects to the login page.
  486
+
  487
+**Optional arguments:**
  488
+
  489
+    * ``login_url``: The URL of the login page to redirect to. This
  490
+      will default to ``/accounts/login/`` if not supplied.
  491
+
  492
+``django.contrib.auth.views.password_change``
  493
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  494
+
  495
+**Description:**
  496
+
  497
+Allows a user to change their password.
  498
+
  499
+**Optional arguments:**
  500
+
  501
+    * ``template_name``: The full name of a template to use for
  502
+      displaying the password change form. This will default to
  503
+      ``registration/password_change_form.html`` if not supplied.
  504
+
  505
+**Template context:**
  506
+
  507
+    * ``form``: The password change form.
  508
+
  509
+``django.contrib.auth.views.password_change_done``
  510
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  511
+
  512
+**Description:**
  513
+
  514
+The page shown after a user has changed their password.
  515
+
  516
+**Optional arguments:**
  517
+
  518
+    * ``template_name``: The full name of a template to use. This will
  519
+      default to ``registration/password_change_done.html`` if not
  520
+      supplied.
  521
+
  522
+``django.contrib.auth.views.password_reset``
  523
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  524
+
  525
+**Description:**
  526
+
  527
+Allows a user to reset their password, and sends them the new password
  528
+in an email.
  529
+
  530
+**Optional arguments:**
  531
+
  532
+    * ``template_name``: The full name of a template to use for
  533
+      displaying the password reset form. This will default to
  534
+      ``registration/password_reset_form.html`` if not supplied.
  535
+
  536
+    * ``email_template_name``: The full name of a template to use for
  537
+      generating the email with the new password. This will default to
  538
+      ``registration/password_reset_email.html`` if not supplied.
  539
+
  540
+**Template context:**
  541
+
  542
+    * ``form``: The form for resetting the user's password.
  543
+
  544
+``django.contrib.auth.views.password_reset_done``
  545
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  546
+
  547
+**Description:**
  548
+
  549
+The page shown after a user has reset their password.
  550
+
  551
+**Optional arguments:**
  552
+
  553
+    * ``template_name``: The full name of a template to use. This will
  554
+      default to ``registration/password_reset_done.html`` if not
  555
+      supplied.
  556
+
  557
+``django.contrib.auth.views.redirect_to_login``
  558
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  559
+
  560
+**Description:**
  561
+
  562
+Redirects to the login page, and then back to another URL after a
  563
+successful login.
  564
+
  565
+**Required arguments:**
  566
+
  567
+    * ``next``: The URL to redirect to after a successful login.
  568
+
  569
+**Optional arguments:**
  570
+
  571
+    * ``login_url``: The URL of the login page to redirect to. This
  572
+      will default to ``/accounts/login/`` if not supplied.
  573
+
  574
+Built-in manipulators
  575
+---------------------
  576
+
  577
+If you don't want to use the built-in views, but want the convenience
  578
+of not having to write manipulators for this functionality, the
  579
+authentication system provides several built-in manipulators:
  580
+
  581
+    * ``django.contrib.auth.forms.AdminPasswordChangeForm``: A
  582
+      manipulator used in the admin interface to change a user's
  583
+      password.
  584
+
  585
+    * ``django.contrib.auth.forms.AuthenticationForm``: A manipulator
  586
+      for logging a user in.
  587
+
  588
+    * ``django.contrib.auth.forms.PasswordChangeForm``: A manipulator
  589
+      for allowing a user to change their password.
  590
+
  591
+    * ``django.contrib.auth.forms.PasswordResetForm``: A manipulator
  592
+      for resetting a user's password and emailing the new password to
  593
+      them.
  594
+
  595
+    * ``django.contrib.auth.forms.UserCreationForm``: A manipulator
  596
+      for creating a new user.
  597
+
447 598
 Limiting access to logged-in users that pass a test
448 599
 ---------------------------------------------------
449 600
 

0 notes on commit b581d73

Please sign in to comment.
Something went wrong with that request. Please try again.