mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
Merge pull request #759 from tonioo/django-passwords
Passwords complexity rules.
This commit is contained in:
@@ -133,6 +133,16 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
|
||||
MODOBOA_API_URL = 'http://api.modoboa.org/1/'
|
||||
|
||||
# django-passwords
|
||||
|
||||
PASSWORD_MIN_LENGTH = 8
|
||||
|
||||
PASSWORD_COMPLEXITY = {
|
||||
"UPPER": 1,
|
||||
"LOWER": 1,
|
||||
"DIGITS": 1
|
||||
}
|
||||
|
||||
# Logging configuration
|
||||
|
||||
LOGGING = {
|
||||
|
||||
@@ -8,7 +8,7 @@ BOWER_COMPONENTS_ROOT = os.path.join(
|
||||
BOWER_INSTALLED_APPS = (
|
||||
"jquery#1.9",
|
||||
"jquery-ui#1.11",
|
||||
"bootstrap#3.3.1",
|
||||
"bootstrap#3.3.5",
|
||||
"bootstrap-select#1.6",
|
||||
"d3#3.5.0",
|
||||
"eonasdan-bootstrap-datetimepicker#3.1.3",
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext as _, ugettext_lazy
|
||||
|
||||
from passwords.fields import PasswordField
|
||||
|
||||
from modoboa.core.models import User
|
||||
from modoboa.lib import parameters
|
||||
|
||||
@@ -29,11 +31,11 @@ class ProfileForm(forms.ModelForm):
|
||||
label=ugettext_lazy("Old password"), required=False,
|
||||
widget=forms.PasswordInput(attrs={"class": "form-control"})
|
||||
)
|
||||
newpassword = forms.CharField(
|
||||
newpassword = PasswordField(
|
||||
label=ugettext_lazy("New password"), required=False,
|
||||
widget=forms.PasswordInput(attrs={"class": "form-control"})
|
||||
)
|
||||
confirmation = forms.CharField(
|
||||
confirmation = PasswordField(
|
||||
label=ugettext_lazy("Confirmation"), required=False,
|
||||
widget=forms.PasswordInput(attrs={"class": "form-control"})
|
||||
)
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
id="uprefs_form">{% csrf_token %}
|
||||
{% render_form form %}
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary col-lg-offset-8 col-md-offset-7 col-sm-offset-7 col-lg-1 col-md-2 col-sm-2" id="update" name="update">{% trans 'Update' %}</button>
|
||||
<button type="submit" class="btn btn-primary col-lg-offset-8 col-sm-offset-7 col-lg-1 col-sm-2" id="update" name="update">{% trans 'Update' %}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
+11
-4
@@ -23,11 +23,11 @@ class ProfileTestCase(ModoTestCase):
|
||||
"""
|
||||
self.ajax_post(reverse("core:user_profile"),
|
||||
{"oldpassword": "password",
|
||||
"newpassword": "titi", "confirmation": "titi"})
|
||||
"newpassword": "12345Toi", "confirmation": "12345Toi"})
|
||||
self.clt.logout()
|
||||
|
||||
self.assertEqual(
|
||||
self.clt.login(username="admin", password="titi"), True
|
||||
self.clt.login(username="admin", password="12345Toi"), True
|
||||
)
|
||||
self.assertEqual(
|
||||
self.clt.login(username="user@test.com", password="toto"), True
|
||||
@@ -36,9 +36,16 @@ class ProfileTestCase(ModoTestCase):
|
||||
self.ajax_post(
|
||||
reverse("core:user_profile"),
|
||||
{"oldpassword": "toto",
|
||||
"newpassword": "tutu", "confirmation": "tutu"}
|
||||
"newpassword": "tutu", "confirmation": "tutu"},
|
||||
status=400
|
||||
)
|
||||
|
||||
self.ajax_post(
|
||||
reverse("core:user_profile"),
|
||||
{"oldpassword": "toto",
|
||||
"newpassword": "Toto1234", "confirmation": "Toto1234"}
|
||||
)
|
||||
self.clt.logout()
|
||||
self.assertTrue(
|
||||
self.clt.login(username="user@test.com", password="tutu")
|
||||
self.clt.login(username="user@test.com", password="Toto1234")
|
||||
)
|
||||
|
||||
@@ -8,3 +8,4 @@ passlib
|
||||
django-versionfield2>=0.3.3
|
||||
requests
|
||||
django-xforwardedfor-middleware
|
||||
django-passwords==0.3.3
|
||||
|
||||
Reference in New Issue
Block a user