Commit 81481ba1 authored by chirac's avatar chirac
Browse files

Modifie la façon dont les erreurs sur les reinit de mdp sont gérées

parent f64115ed
......@@ -39,6 +39,13 @@ class PassForm(forms.Form):
passwd1 = forms.CharField(label=u'Nouveau mot de passe', max_length=255, validators=[MinLengthValidator(8)], widget=forms.PasswordInput)
passwd2 = forms.CharField(label=u'Saisir à nouveau le mot de passe', max_length=255, validators=[MinLengthValidator(8)], widget=forms.PasswordInput)
def clean_passwd2(self):
# Check that the two password entries match
password1 = self.cleaned_data.get("passwd1")
password2 = self.cleaned_data.get("passwd2")
if password1 and password2 and password1 != password2:
raise forms.ValidationError("Passwords don't match")
return password2
class UserCreationForm(forms.ModelForm):
"""A form for creating new users. Includes all the required
......@@ -42,6 +42,7 @@ import ldapdb.models.fields
from re2o.settings import RIGHTS_LINK, LDAP, GID_RANGES,UID_RANGES
import re, uuid
import datetime
from re2o.login import hashNT
from django.utils import timezone
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
......@@ -486,6 +487,11 @@ class User(AbstractBaseUser):
def all_machines(self):
return Interface.objects.filter(machine__in=Machine.objects.filter(user=self))
def set_user_password(self, password):
self.pwd_ntlm = hashNT(password)
def __str__(self):
return self.pseudo
......@@ -65,11 +65,7 @@ def form(ctx, template, request):
def password_change_action(u_form, user, request, req=False):
""" Fonction qui effectue le changeemnt de mdp bdd"""
if u_form.cleaned_data['passwd1'] != u_form.cleaned_data['passwd2']:
messages.error(request, "Les 2 mots de passe différent")
return form({'userform': u_form}, 'users/user.html', request)
user.pwd_ntlm = hashNT(u_form.cleaned_data['passwd1'])
with transaction.atomic(), reversion.create_revision():
reversion.set_comment("Réinitialisation du mot de passe")
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