Loading django/contrib/auth/tests/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ from django.contrib.auth.tests.management import GetDefaultUsernameTestCase from django.contrib.auth.tests.models import ProfileTestCase from django.contrib.auth.tests.signals import SignalTestCase from django.contrib.auth.tests.tokens import TokenGeneratorTest from django.contrib.auth.tests.views import (PasswordResetTest, from django.contrib.auth.tests.views import (AuthViewNamedURLTests, PasswordResetTest, ChangePasswordTest, LoginTest, LogoutTest, LoginURLSettings) # The password for the fixture data users is 'password' django/contrib/auth/tests/views.py +28 −0 Original line number Diff line number Diff line Loading @@ -8,11 +8,13 @@ from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME from django.contrib.auth.forms import AuthenticationForm from django.contrib.sites.models import Site, RequestSite from django.contrib.auth.models import User from django.core.urlresolvers import NoReverseMatch from django.test import TestCase from django.core import mail from django.core.urlresolvers import reverse from django.http import QueryDict class AuthViewsTestCase(TestCase): """ Helper base class for all the follow test cases. Loading Loading @@ -45,6 +47,32 @@ class AuthViewsTestCase(TestCase): self.assertTrue(response['Location'].endswith(settings.LOGIN_REDIRECT_URL)) self.assertTrue(SESSION_KEY in self.client.session) class AuthViewNamedURLTests(AuthViewsTestCase): urls = 'django.contrib.auth.urls' def test_named_urls(self): "Named URLs should be reversible" expected_named_urls = [ ('login', [], {}), ('logout', [], {}), ('password_change', [], {}), ('password_change_done', [], {}), ('password_reset', [], {}), ('password_reset_done', [], {}), ('password_reset_confirm', [], { 'uidb36': 'aaaaaaa', 'token': '1111-aaaaa', }), ('password_reset_complete', [], {}), ] for name, args, kwargs in expected_named_urls: try: reverse(name, args=args, kwargs=kwargs) except NoReverseMatch: self.fail("Reversal of url named '%s' failed with NoReverseMatch" % name) class PasswordResetTest(AuthViewsTestCase): def test_email_not_found(self): Loading django/contrib/auth/urls.py +15 −13 Original line number Diff line number Diff line # These URLs are normally mapped to /admin/urls.py. This URLs file is # provided as a convenience to those who want to deploy these URLs elsewhere. # This file is also used to provide a reliable view deployment for test purposes. # The views used below are normally mapped in django.contrib.admin.urls.py # This URLs file is used to provide a reliable view deployment for test purposes. # It is also provided as a convenience to those who want to deploy these URLs # elsewhere. from django.conf.urls import patterns from django.conf.urls import patterns, url urlpatterns = patterns('', (r'^login/$', 'django.contrib.auth.views.login'), (r'^logout/$', 'django.contrib.auth.views.logout'), (r'^password_change/$', 'django.contrib.auth.views.password_change'), (r'^password_change/done/$', 'django.contrib.auth.views.password_change_done'), (r'^password_reset/$', 'django.contrib.auth.views.password_reset'), (r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done'), (r'^reset/(?P<uidb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', 'django.contrib.auth.views.password_reset_confirm'), (r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'), url(r'^login/$', 'django.contrib.auth.views.login', name='login'), url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'), url(r'^password_change/$', 'django.contrib.auth.views.password_change', name='password_change'), url(r'^password_change/done/$', 'django.contrib.auth.views.password_change_done', name='password_change_done'), url(r'^password_reset/$', 'django.contrib.auth.views.password_reset', name='password_reset'), url(r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'), url(r'^reset/(?P<uidb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', 'django.contrib.auth.views.password_reset_confirm', name='password_reset_confirm'), url(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete', name='password_reset_complete'), ) docs/topics/auth.txt +24 −0 Original line number Diff line number Diff line Loading @@ -823,6 +823,11 @@ The login_required decorator .. function:: views.login(request, [template_name, redirect_field_name, authentication_form]) **URL name:** ``login`` See :doc:`the URL documentation </topics/http/urls>` for details on using named URL patterns. Here's what ``django.contrib.auth.views.login`` does: * If called via ``GET``, it displays a login form that POSTs to the Loading Loading @@ -938,6 +943,11 @@ includes a few other useful built-in views located in Logs a user out. **URL name:** ``logout`` See :doc:`the URL documentation </topics/http/urls>` for details on using named URL patterns. **Optional arguments:** * ``next_page``: The URL to redirect to after logout. Loading Loading @@ -970,6 +980,8 @@ includes a few other useful built-in views located in Logs a user out, then redirects to the login page. **URL name:** No default URL provided **Optional arguments:** * ``login_url``: The URL of the login page to redirect to. Loading @@ -979,6 +991,8 @@ includes a few other useful built-in views located in Allows a user to change their password. **URL name:** ``password_change`` **Optional arguments:** * ``template_name``: The full name of a template to use for Loading @@ -1003,6 +1017,8 @@ includes a few other useful built-in views located in The page shown after a user has changed their password. **URL name:** ``password_change_done`` **Optional arguments:** * ``template_name``: The full name of a template to use. Loading @@ -1024,6 +1040,8 @@ includes a few other useful built-in views located in will not be able to request a password reset to prevent misuse when using an external authentication source like LDAP. **URL name:** ``password_reset`` **Optional arguments:** * ``template_name``: The full name of a template to use for Loading Loading @@ -1099,6 +1117,8 @@ includes a few other useful built-in views located in password. This view is called by default if the :func:`password_reset` view doesn't have an explicit ``post_reset_redirect`` URL set. **URL name:** ``password_reset_done`` **Optional arguments:** * ``template_name``: The full name of a template to use. Loading @@ -1109,6 +1129,8 @@ includes a few other useful built-in views located in Presents a form for entering a new password. **URL name:** ``password_reset_confirm`` **Optional arguments:** * ``uidb36``: The user's id encoded in base 36. Defaults to ``None``. Loading Loading @@ -1142,6 +1164,8 @@ includes a few other useful built-in views located in Presents a view which informs the user that the password has been successfully changed. **URL name:** ``password_reset_complete`` **Optional arguments:** * ``template_name``: The full name of a template to display the view. Loading Loading
django/contrib/auth/tests/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ from django.contrib.auth.tests.management import GetDefaultUsernameTestCase from django.contrib.auth.tests.models import ProfileTestCase from django.contrib.auth.tests.signals import SignalTestCase from django.contrib.auth.tests.tokens import TokenGeneratorTest from django.contrib.auth.tests.views import (PasswordResetTest, from django.contrib.auth.tests.views import (AuthViewNamedURLTests, PasswordResetTest, ChangePasswordTest, LoginTest, LogoutTest, LoginURLSettings) # The password for the fixture data users is 'password'
django/contrib/auth/tests/views.py +28 −0 Original line number Diff line number Diff line Loading @@ -8,11 +8,13 @@ from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME from django.contrib.auth.forms import AuthenticationForm from django.contrib.sites.models import Site, RequestSite from django.contrib.auth.models import User from django.core.urlresolvers import NoReverseMatch from django.test import TestCase from django.core import mail from django.core.urlresolvers import reverse from django.http import QueryDict class AuthViewsTestCase(TestCase): """ Helper base class for all the follow test cases. Loading Loading @@ -45,6 +47,32 @@ class AuthViewsTestCase(TestCase): self.assertTrue(response['Location'].endswith(settings.LOGIN_REDIRECT_URL)) self.assertTrue(SESSION_KEY in self.client.session) class AuthViewNamedURLTests(AuthViewsTestCase): urls = 'django.contrib.auth.urls' def test_named_urls(self): "Named URLs should be reversible" expected_named_urls = [ ('login', [], {}), ('logout', [], {}), ('password_change', [], {}), ('password_change_done', [], {}), ('password_reset', [], {}), ('password_reset_done', [], {}), ('password_reset_confirm', [], { 'uidb36': 'aaaaaaa', 'token': '1111-aaaaa', }), ('password_reset_complete', [], {}), ] for name, args, kwargs in expected_named_urls: try: reverse(name, args=args, kwargs=kwargs) except NoReverseMatch: self.fail("Reversal of url named '%s' failed with NoReverseMatch" % name) class PasswordResetTest(AuthViewsTestCase): def test_email_not_found(self): Loading
django/contrib/auth/urls.py +15 −13 Original line number Diff line number Diff line # These URLs are normally mapped to /admin/urls.py. This URLs file is # provided as a convenience to those who want to deploy these URLs elsewhere. # This file is also used to provide a reliable view deployment for test purposes. # The views used below are normally mapped in django.contrib.admin.urls.py # This URLs file is used to provide a reliable view deployment for test purposes. # It is also provided as a convenience to those who want to deploy these URLs # elsewhere. from django.conf.urls import patterns from django.conf.urls import patterns, url urlpatterns = patterns('', (r'^login/$', 'django.contrib.auth.views.login'), (r'^logout/$', 'django.contrib.auth.views.logout'), (r'^password_change/$', 'django.contrib.auth.views.password_change'), (r'^password_change/done/$', 'django.contrib.auth.views.password_change_done'), (r'^password_reset/$', 'django.contrib.auth.views.password_reset'), (r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done'), (r'^reset/(?P<uidb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', 'django.contrib.auth.views.password_reset_confirm'), (r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'), url(r'^login/$', 'django.contrib.auth.views.login', name='login'), url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'), url(r'^password_change/$', 'django.contrib.auth.views.password_change', name='password_change'), url(r'^password_change/done/$', 'django.contrib.auth.views.password_change_done', name='password_change_done'), url(r'^password_reset/$', 'django.contrib.auth.views.password_reset', name='password_reset'), url(r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'), url(r'^reset/(?P<uidb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', 'django.contrib.auth.views.password_reset_confirm', name='password_reset_confirm'), url(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete', name='password_reset_complete'), )
docs/topics/auth.txt +24 −0 Original line number Diff line number Diff line Loading @@ -823,6 +823,11 @@ The login_required decorator .. function:: views.login(request, [template_name, redirect_field_name, authentication_form]) **URL name:** ``login`` See :doc:`the URL documentation </topics/http/urls>` for details on using named URL patterns. Here's what ``django.contrib.auth.views.login`` does: * If called via ``GET``, it displays a login form that POSTs to the Loading Loading @@ -938,6 +943,11 @@ includes a few other useful built-in views located in Logs a user out. **URL name:** ``logout`` See :doc:`the URL documentation </topics/http/urls>` for details on using named URL patterns. **Optional arguments:** * ``next_page``: The URL to redirect to after logout. Loading Loading @@ -970,6 +980,8 @@ includes a few other useful built-in views located in Logs a user out, then redirects to the login page. **URL name:** No default URL provided **Optional arguments:** * ``login_url``: The URL of the login page to redirect to. Loading @@ -979,6 +991,8 @@ includes a few other useful built-in views located in Allows a user to change their password. **URL name:** ``password_change`` **Optional arguments:** * ``template_name``: The full name of a template to use for Loading @@ -1003,6 +1017,8 @@ includes a few other useful built-in views located in The page shown after a user has changed their password. **URL name:** ``password_change_done`` **Optional arguments:** * ``template_name``: The full name of a template to use. Loading @@ -1024,6 +1040,8 @@ includes a few other useful built-in views located in will not be able to request a password reset to prevent misuse when using an external authentication source like LDAP. **URL name:** ``password_reset`` **Optional arguments:** * ``template_name``: The full name of a template to use for Loading Loading @@ -1099,6 +1117,8 @@ includes a few other useful built-in views located in password. This view is called by default if the :func:`password_reset` view doesn't have an explicit ``post_reset_redirect`` URL set. **URL name:** ``password_reset_done`` **Optional arguments:** * ``template_name``: The full name of a template to use. Loading @@ -1109,6 +1129,8 @@ includes a few other useful built-in views located in Presents a form for entering a new password. **URL name:** ``password_reset_confirm`` **Optional arguments:** * ``uidb36``: The user's id encoded in base 36. Defaults to ``None``. Loading Loading @@ -1142,6 +1164,8 @@ includes a few other useful built-in views located in Presents a view which informs the user that the password has been successfully changed. **URL name:** ``password_reset_complete`` **Optional arguments:** * ``template_name``: The full name of a template to display the view. Loading