Add possibility to change password
This commit is contained in:
parent
f559c20b65
commit
15da1c8b51
4 changed files with 33 additions and 5 deletions
17
authentication/templates/authentication/change_password.html
Normal file
17
authentication/templates/authentication/change_password.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load crispy_forms_filters %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{% block title %}Change password{% endblock %}</h1>
|
||||
|
||||
<div id="login">
|
||||
<form method="post">
|
||||
{% if next %}
|
||||
<input type="hidden" name="next" value="{{ next }}"/>
|
||||
{% endif %}
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
<button type="submit" class="btn btn-primary">Change password</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,5 +1,6 @@
|
|||
from django.conf.urls import url
|
||||
from django.contrib.auth.views import login, logout
|
||||
from django.contrib.auth.views import login, logout, password_change
|
||||
from authentication.views import password_change_done
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^login/$',
|
||||
|
@ -12,4 +13,6 @@ urlpatterns = [
|
|||
{'next_page': 'home'},
|
||||
name='auth_logout'
|
||||
),
|
||||
url(r'^password/change/$', password_change, {'template_name': 'authentication/change_password.html'}, name='password_change'),
|
||||
url(r'^password/change/done/$', password_change_done, name='password_change_done'),
|
||||
]
|
||||
|
|
7
authentication/views.py
Normal file
7
authentication/views.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.contrib import messages
|
||||
|
||||
|
||||
def password_change_done(request):
|
||||
messages.success(request, "Password changed successfully")
|
||||
return render(request, 'refunds/home.html')
|
|
@ -24,20 +24,21 @@
|
|||
<ul class="nav navbar-nav navbar-right">
|
||||
{% if not user.is_authenticated %}
|
||||
<li><a href="{% url 'auth_login' %}?next={{ request.path }}">Login</a></li>
|
||||
{% elif user.is_staff %}
|
||||
{% else %}
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
{% firstof user.get_full_name user.username %} <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
{% if user.is_staff %}
|
||||
<li><a href="{% url 'admin:index' %}">Admin</a></li>
|
||||
{% endif %}
|
||||
<li><a href="{% url 'password_change' %}">Change password</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="{% url 'auth_logout' %}?next={{ request.path }}">Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
<li><a href="{% url 'auth_logout' %}?next={{ request.path }}">Logout</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div><!-- /.navbar-collapse -->
|
||||
|
|
Loading…
Reference in a new issue