diff --git a/modoboa/core/commands/templates/settings.py.tpl b/modoboa/core/commands/templates/settings.py.tpl index 6354777e1..acedc64b1 100644 --- a/modoboa/core/commands/templates/settings.py.tpl +++ b/modoboa/core/commands/templates/settings.py.tpl @@ -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 = { diff --git a/modoboa/core/dev_settings.py b/modoboa/core/dev_settings.py index 936302132..9b3150c18 100644 --- a/modoboa/core/dev_settings.py +++ b/modoboa/core/dev_settings.py @@ -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", diff --git a/modoboa/core/forms.py b/modoboa/core/forms.py index a72f13d44..2a35c7b6e 100644 --- a/modoboa/core/forms.py +++ b/modoboa/core/forms.py @@ -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"}) ) diff --git a/modoboa/core/templates/core/user_profile.html b/modoboa/core/templates/core/user_profile.html index 1732fad2c..15fb395d4 100644 --- a/modoboa/core/templates/core/user_profile.html +++ b/modoboa/core/templates/core/user_profile.html @@ -5,6 +5,6 @@ id="uprefs_form">{% csrf_token %} {% render_form form %}
- +
diff --git a/modoboa/core/tests.py b/modoboa/core/tests.py index ee070a693..3a8e0aa42 100644 --- a/modoboa/core/tests.py +++ b/modoboa/core/tests.py @@ -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") ) diff --git a/requirements.txt b/requirements.txt index 8acc68d56..862495789 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ passlib django-versionfield2>=0.3.3 requests django-xforwardedfor-middleware +django-passwords==0.3.3