Commit 6e54fa07 authored by Skia's avatar Skia

WIP: password change/reset forms

parent 04bbf0db
{% extends "core/base.html" %}
{% block content %}
{% if form.errors %}
<p>Your passwords didn't match. Please try again.</p>
{% endif %}
<form method="post" action="{% url 'core:password_change' %}">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Change!" />
</form>
{% endblock %}
{% extends "core/base.html" %}
{% block content %}
You successfully changed your password!
{% if form.errors %}
<p>Your passwords didn't match. Please try again.</p>
{% endif %}
{% endblock %}
......@@ -4,10 +4,19 @@ from core.views import *
urlpatterns = [
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'^password_change/done$', password_change_done, name='password_change_done'),
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'),
url(r'^register$', register, name='register'),
url(r'^user/$', user, name='user_list'),
url(r'^user/(?P<user_id>[0-9]+)/$', user, name='user_profile'),
url(r'^user/(?P<user_id>[0-9]+)/edit$', user_edit, name='user_edit'),
......
# This file contains all the views that concern the user model
from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth import logout as auth_logout
from django.contrib.auth import views
from django.contrib.auth import logout as auth_logout, views
from django.contrib.auth.forms import PasswordChangeForm
from django.core.urlresolvers import reverse
import logging
......@@ -9,6 +8,44 @@ import logging
from core.views.forms import RegisteringForm, LoginForm, UserEditForm
from core.models import User
def login(request):
"""
The login view
Needs to be improve with correct handling of form exceptions
"""
return views.login(request, template_name="core/login.html")
def logout(request):
"""
The logout view
"""
return views.logout_then_login(request)
def password_change(request):
"""
Allows a user to change its password
"""
return views.password_change(request, template_name="core/password_change.html")
def password_change_done(request):
"""
Allows a user to change its password
"""
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_done(request):
pass
def password_reset(request):
pass
def register(request):
context = {'title': 'Register a user'}
if request.method == 'POST':
......@@ -27,20 +64,6 @@ def register(request):
context['form'] = form.as_p()
return render(request, "core/register.html", context)
def login(request):
"""
The login view
Needs to be improve with correct handling of form exceptions
"""
return views.login(request, template_name="core/login.html")
def logout(request):
"""
The logout view
"""
return views.logout_then_login(request)
def user(request, user_id=None):
"""
Display a user's profile
......
......@@ -103,4 +103,5 @@ USE_TZ = True
STATIC_URL = '/static/'
AUTH_USER_MODEL = 'core.User'
LOGIN_URL = '/login'
LOGOUT_URL = '/logout'
LOGIN_REDIRECT_URL = '/'
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