Commit 431b81cd authored by Skia's avatar Skia

Make all the lost password procedure

parent 6e54fa07
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
{% block content %} {% block content %}
You successfully changed your password!
{% if form.errors %} {% if form.errors %}
<p>Your passwords didn't match. Please try again.</p> <p>Your passwords didn't match. Please try again.</p>
{% else %}
You successfully changed your password!
{% endif %} {% endif %}
{% endblock %} {% endblock %}
......
{% extends "core/base.html" %}
{% block content %}
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Reset!" />
</form>
{% endblock %}
{% extends "core/base.html" %}
{% block content %}
<p>You successfully reset your password!</p>
<a href="{% url 'core:login' %}">Login</a>
{% endblock %}
{% extends "core/base.html" %}
{% block content %}
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Reset" />
</form>
{% endblock %}
{% 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 %}
...@@ -3,15 +3,15 @@ from django.conf.urls import url, include ...@@ -3,15 +3,15 @@ from django.conf.urls import url, include
from core.views import * from core.views import *
urlpatterns = [ urlpatterns = [
url('^', include('django.contrib.auth.urls')), #url('^', include('django.contrib.auth.urls')),
url(r'^$', index, name='index'), url(r'^$', index, name='index'),
url(r'^login$', login, name='login'), url(r'^login/$', login, name='login'),
url(r'^logout$', logout, name='logout'), url(r'^logout/$', logout, name='logout'),
url(r'^password_change$', password_change, name='password_change'), url(r'^password_change/$', password_change, name='password_change'),
url(r'^password_change/done$', password_change_done, name='password_change_done'), 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'^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/(?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'), url(r'^reset/done/$', password_reset_complete, name='password_reset_complete'),
......
...@@ -3,6 +3,7 @@ from django.shortcuts import render, redirect, get_object_or_404 ...@@ -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 import logout as auth_logout, views
from django.contrib.auth.forms import PasswordChangeForm from django.contrib.auth.forms import PasswordChangeForm
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.core.mail import send_mail
import logging import logging
from core.views.forms import RegisteringForm, LoginForm, UserEditForm from core.views.forms import RegisteringForm, LoginForm, UserEditForm
...@@ -26,7 +27,7 @@ def password_change(request): ...@@ -26,7 +27,7 @@ def password_change(request):
""" """
Allows a user to change its password 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): def password_change_done(request):
""" """
...@@ -34,16 +35,27 @@ 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") return views.password_change_done(request, template_name="core/password_change_done.html")
def password_reset_confirm(request): def password_reset(request):
pass return views.password_reset(request,
template_name="core/password_reset.html",
def password_reset_complete(request): email_template_name="core/password_reset_email.html",
pass post_reset_redirect="core:password_reset",
)
def password_reset_done(request): def password_reset_done(request):
return views.password_reset_done(request)
pass 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 pass
def register(request): def register(request):
......
...@@ -101,7 +101,15 @@ USE_TZ = True ...@@ -101,7 +101,15 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.8/howto/static-files/ # https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = '/static/'
# Auth configuration
AUTH_USER_MODEL = 'core.User' AUTH_USER_MODEL = 'core.User'
LOGIN_URL = '/login' LOGIN_URL = '/login'
LOGOUT_URL = '/logout' LOGOUT_URL = '/logout'
LOGIN_REDIRECT_URL = '/' LOGIN_REDIRECT_URL = '/'
DEFAULT_FROM_EMAIL="bibou@git.an"
# Email
EMAIL_HOST="localhost"
EMAIL_PORT=25
...@@ -17,6 +17,6 @@ from django.conf.urls import include, url ...@@ -17,6 +17,6 @@ from django.conf.urls import include, url
from django.contrib import admin from django.contrib import admin
urlpatterns = [ 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)), url(r'^admin/', include(admin.site.urls)),
] ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment