-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Added password expiration #359
Closes #359 Co-authored-by: Federico Capoano <[email protected]>
- Loading branch information
1 parent
f363505
commit 33545bb
Showing
29 changed files
with
1,000 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
openwisp_users/accounts/static/openwisp-users/accounts/css/change-password.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
form.password_change p { | ||
overflow: hidden; | ||
padding: 15px; | ||
font-size: 15px; | ||
border-bottom: 1px solid var(--hairline-color); | ||
box-sizing: border-box; | ||
} | ||
form.password_change label { | ||
display: inline-block; | ||
padding: 6px 10px 0 0; | ||
width: 160px; | ||
word-wrap: break-word; | ||
line-height: 1; | ||
font-weight: bold; | ||
} | ||
#main form.password_change .submit-row { | ||
text-align: left; | ||
} | ||
#main form.password_change .default { | ||
float: unset; | ||
} | ||
#main form.password_change .submit-row input { | ||
margin: 0 15px 0 0; | ||
} | ||
#main .submit-row .button { | ||
font-size: 14px; | ||
padding: 0.625rem 1rem; | ||
} | ||
#main .errorlist { | ||
margin: 5px 0; | ||
} | ||
#main .errorlist li { | ||
font-size: 15px; | ||
font-weight: bold; | ||
} | ||
|
||
@media (max-width: 767px) { | ||
#main form.password_change label { | ||
padding: 0 0 10px; | ||
width: 100%; | ||
} | ||
|
||
#main form.password_change input { | ||
width: 100%; | ||
} | ||
|
||
#main form.password_change .submit-row .button { | ||
width: 100%; | ||
margin: 0 0 15px 0; | ||
padding-right: 0; | ||
padding-left: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
{% extends "admin/base_site.html" %} | ||
{% block title %}OpenWISP2{% endblock %} | ||
|
||
{% block breadcrumbs %}{% endblock %} |
55 changes: 55 additions & 0 deletions
55
openwisp_users/accounts/templates/account/password_change.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{% extends "account/base.html" %} | ||
|
||
{% load i18n %} | ||
{% load static %} | ||
|
||
{% block title %}{% trans "Change Password" %}{% endblock %} | ||
{% block extrahead %} | ||
<link rel="stylesheet" type="text/css" href="{% static 'openwisp-users/accounts/css/change-password.css' %}" /> | ||
{% endblock %} | ||
|
||
{% block extrastyle %} | ||
{{ block.super }} | ||
{{ form.media.css }} | ||
{% endblock extrastyle %} | ||
|
||
{% block content %} | ||
<h1>{% trans "Change Password" %}</h1> | ||
|
||
<form method="POST" action="{% url 'account_change_password' %}" class="password_change"> | ||
{% csrf_token %} | ||
<fieldset class="aligned"> | ||
<div class="form-row"> | ||
{{ form.oldpassword.errors }} | ||
{{ form.oldpassword.label_tag }} | ||
{{ form.oldpassword }} | ||
{% if form.oldpassword.help_text %} | ||
<div class="help" {% if form.oldpassword.id_for_label %} id="{{ form.oldpassword.id_for_label }}_helptext" | ||
{% endif %}>{{ form.oldpassword.help_text|safe }}</div> | ||
{% endif %} | ||
</div> | ||
<div class="form-row"> | ||
{{ form.password1.errors }} | ||
{{ form.password1.label_tag }} | ||
{{ form.password1 }} | ||
{% if form.password1.help_text %} | ||
<div class="help" {% if form.password1.id_for_label %} id="{{ form.password1.id_for_label }}_helptext" | ||
{% endif %}>{{ form.password1.help_text|safe }}</div> | ||
{% endif %} | ||
</div> | ||
<div class="form-row"> | ||
{{ form.password2.errors }} | ||
{{ form.password2.label_tag }} | ||
{{ form.password2 }} | ||
{% if form.password2.help_text %} | ||
<div class="help" {% if form.password2.id_for_label %} id="{{ form.password2.id_for_label }}_helptext" | ||
{% endif %}>{{ form.password2.help_text|safe }}</div> | ||
{% endif %} | ||
</div> | ||
</fieldset> | ||
<div class="form-row submit-row"> | ||
<input type="submit" name="action" value="{% translate 'Change password' %}" class="default button"> | ||
<a href="{% url 'account_reset_password' %}" class="button">{% trans "Forgot Password?" %}</a> | ||
</div> | ||
</form> | ||
{% endblock %} |
20 changes: 20 additions & 0 deletions
20
openwisp_users/accounts/templates/account/password_change_success.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{% extends "account/base.html" %} | ||
{% load i18n %} | ||
|
||
{% block extrastyle %} | ||
{{ block.super }} | ||
<style> | ||
.breadcrumbs, .messagelist { | ||
display: none; | ||
} | ||
#content { | ||
margin-top: 10px; | ||
} | ||
#site-name a { cursor: default } | ||
</style> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h1>{% trans "Your password has been changed successfully." %}</h1> | ||
<h1>{% trans "This web page can be closed." %}</h1> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from allauth.account.forms import ChangePasswordForm as BaseChangePasswordForm | ||
from allauth.account.views import PasswordChangeView as BasePasswordChangeView | ||
from django import forms | ||
from django.contrib.auth import REDIRECT_FIELD_NAME | ||
from django.contrib.auth.decorators import login_required | ||
from django.urls import reverse_lazy | ||
from django.views.generic.base import TemplateView | ||
|
||
|
||
class ChangePasswordForm(BaseChangePasswordForm): | ||
next = forms.CharField(widget=forms.HiddenInput, required=False) | ||
|
||
|
||
class PasswordChangeView(BasePasswordChangeView): | ||
form_class = ChangePasswordForm | ||
template_name = 'account/password_change.html' | ||
success_url = reverse_lazy('account_change_password_success') | ||
|
||
def get_success_url(self): | ||
if self.request.POST.get(REDIRECT_FIELD_NAME): | ||
return self.request.POST.get(REDIRECT_FIELD_NAME) | ||
return super().get_success_url() | ||
|
||
def get_initial(self): | ||
data = super().get_initial() | ||
data['next'] = self.request.GET.get(REDIRECT_FIELD_NAME) | ||
return data | ||
|
||
|
||
password_change = login_required(PasswordChangeView.as_view()) | ||
password_change_success = login_required( | ||
TemplateView.as_view(template_name='account/password_change_success.html') | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.