Make all the lost password procedure

This commit is contained in:
Skia 2015-11-26 10:57:26 +01:00
parent 6e54fa075e
commit 431b81cd42
9 changed files with 77 additions and 14 deletions

View File

@ -2,10 +2,11 @@
{% block content %}
You successfully changed your password!
{% if form.errors %}
<p>Your passwords didn't match. Please try again.</p>
{% else %}
You successfully changed your password!
{% endif %}
{% endblock %}

View File

@ -0,0 +1,9 @@
{% extends "core/base.html" %}
{% block content %}
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Reset!" />
</form>
{% endblock %}

View File

@ -0,0 +1,8 @@
{% extends "core/base.html" %}
{% block content %}
<p>You successfully reset your password!</p>
<a href="{% url 'core:login' %}">Login</a>
{% endblock %}

View File

@ -0,0 +1,10 @@
{% extends "core/base.html" %}
{% block content %}
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Reset" />
</form>
{% endblock %}

View File

@ -0,0 +1,15 @@
{% load i18n %}{% autoescape off %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url 'core:password_reset_confirm' uidb64=uid token=token %}
{% endblock %}
{% trans "Your username, in case you've forgotten:" %} {{ user.get_username }}
{% trans "Thanks for using our site!" %}
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
{% endautoescape %}

View File

@ -3,15 +3,15 @@ from django.conf.urls import url, include
from core.views import *
urlpatterns = [
url('^', include('django.contrib.auth.urls')),
#url('^', include('django.contrib.auth.urls')),
url(r'^$', index, name='index'),
url(r'^login$', login, name='login'),
url(r'^logout$', logout, name='logout'),
url(r'^password_change$', password_change, name='password_change'),
url(r'^login/$', login, name='login'),
url(r'^logout/$', logout, name='logout'),
url(r'^password_change/$', password_change, name='password_change'),
url(r'^password_change/done$', password_change_done, name='password_change_done'),
url(r'^password_reset$', password_reset, name='password_reset'),
url(r'^password_reset/$', password_reset, name='password_reset'),
url(r'^password_reset/done$', password_reset_done, name='password_reset_done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', password_reset_confirm, name='password_reset_confirm'),
url(r'^reset/done/$', password_reset_complete, name='password_reset_complete'),

View File

@ -3,6 +3,7 @@ from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth import logout as auth_logout, views
from django.contrib.auth.forms import PasswordChangeForm
from django.core.urlresolvers import reverse
from django.core.mail import send_mail
import logging
from core.views.forms import RegisteringForm, LoginForm, UserEditForm
@ -26,7 +27,7 @@ def password_change(request):
"""
Allows a user to change its password
"""
return views.password_change(request, template_name="core/password_change.html")
return views.password_change(request, template_name="core/password_change.html", post_change_redirect=reverse("core:password_change_done"))
def password_change_done(request):
"""
@ -34,16 +35,27 @@ def password_change_done(request):
"""
return views.password_change_done(request, template_name="core/password_change_done.html")
def password_reset_confirm(request):
pass
def password_reset_complete(request):
pass
def password_reset(request):
return views.password_reset(request,
template_name="core/password_reset.html",
email_template_name="core/password_reset_email.html",
post_reset_redirect="core:password_reset",
)
def password_reset_done(request):
return views.password_reset_done(request)
pass
def password_reset(request):
def password_reset_confirm(request, uidb64=None, token=None):
return views.password_reset_confirm(request, uidb64=uidb64, token=token,
post_reset_redirect="core:password_reset_complete",
template_name="core/password_reset_confirm.html",
)
def password_reset_complete(request):
return views.password_reset_complete(request,
template_name="core/password_reset_complete.html",
)
pass
def register(request):

View File

@ -101,7 +101,15 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
# Auth configuration
AUTH_USER_MODEL = 'core.User'
LOGIN_URL = '/login'
LOGOUT_URL = '/logout'
LOGIN_REDIRECT_URL = '/'
DEFAULT_FROM_EMAIL="bibou@git.an"
# Email
EMAIL_HOST="localhost"
EMAIL_PORT=25

View File

@ -17,6 +17,6 @@ from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^', include('core.urls', namespace="core")),
url(r'^', include('core.urls', namespace="core", app_name="core")),
url(r'^admin/', include(admin.site.urls)),
]