Added a password reset link to default admin login page if a password reset URL is available.
You no longer have to override the admin login page just to get that link to appear! Also provided much better docs for how to plug in the provided password reset mechanism with minimum effort. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17266 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
14ba0df3d0
commit
1c16907199
|
@ -52,3 +52,6 @@ body.login {
|
|||
padding: 1em 0 0 9.4em;
|
||||
}
|
||||
|
||||
.login .password-reset-link {
|
||||
text-align: center;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n admin_static %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" />{% endblock %}
|
||||
|
||||
|
@ -38,6 +39,12 @@
|
|||
<input type="hidden" name="this_is_the_login_form" value="1" />
|
||||
<input type="hidden" name="next" value="{{ next }}" />
|
||||
</div>
|
||||
{% url 'admin_password_reset' as password_reset_url %}
|
||||
{% if password_reset_url %}
|
||||
<div class="password-reset-link">
|
||||
<a href="{{ password_reset_url }}">{% trans 'Forgotten your password or username?' %}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="submit-row">
|
||||
<label> </label><input type="submit" value="{% trans 'Log in' %}" />
|
||||
</div>
|
||||
|
|
|
@ -546,6 +546,11 @@ Django 1.4 also includes several smaller improvements worth noting:
|
|||
For more details, see the documentation for
|
||||
:meth:`~django.db.models.query.QuerySet.distinct`.
|
||||
|
||||
* The admin login page will add a password reset link if you include a URL with
|
||||
the name `'admin_password_reset'` in your urls.py, so plugging in the builtin
|
||||
password reset mechanism and making it available is now much easier. For
|
||||
details, see :ref:`auth_password_reset`.
|
||||
|
||||
Backwards incompatible changes in 1.4
|
||||
=====================================
|
||||
|
||||
|
|
|
@ -371,6 +371,34 @@ Don't set the :attr:`~django.contrib.auth.models.User.password` attribute
|
|||
directly unless you know what you're doing. This is explained in the next
|
||||
section.
|
||||
|
||||
.. _auth_password_reset:
|
||||
|
||||
User-requested password resets
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
There is a bundled reset mechanism that integrates into the admin, allowing
|
||||
users to reset their passwords by email. It can be customized and is described
|
||||
in detail below under :func:`~django.contrib.auth.views.password_reset`. To
|
||||
enable it without customization, add lines something like the following to your
|
||||
urls.py:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
url(r'^admin/password_reset/$', 'django.contrib.auth.views.password_reset', name='admin_password_reset'),
|
||||
(r'^admin/password_reset/done/$', 'django.contrib.auth.views.password_reset_done'),
|
||||
(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),
|
||||
(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),
|
||||
|
||||
(This assumes you've added the admin at ``admin/``, and requires that you put
|
||||
the URLs starting with ``^admin/`` before the line that includes the admin app
|
||||
itself).
|
||||
|
||||
.. versionchanged:: 1.4
|
||||
|
||||
The presence of the 'admin_password_reset' named URL will cause a "forgotten
|
||||
your password?" link to appear on the default admin login page under the
|
||||
password box.
|
||||
|
||||
.. _auth_password_storage:
|
||||
|
||||
How Django stores passwords
|
||||
|
|
Loading…
Reference in New Issue