mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-26 00:43:46 +00:00
Modifie la façon dont les erreurs sur les reinit de mdp sont gérées
This commit is contained in:
parent
70bf1b9e4f
commit
9a94d4a6ba
3 changed files with 14 additions and 5 deletions
|
@ -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)
|
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)
|
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):
|
class UserCreationForm(forms.ModelForm):
|
||||||
"""A form for creating new users. Includes all the required
|
"""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
|
from re2o.settings import RIGHTS_LINK, LDAP, GID_RANGES,UID_RANGES
|
||||||
import re, uuid
|
import re, uuid
|
||||||
import datetime
|
import datetime
|
||||||
|
from re2o.login import hashNT
|
||||||
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
|
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
|
||||||
|
@ -486,6 +487,11 @@ class User(AbstractBaseUser):
|
||||||
def all_machines(self):
|
def all_machines(self):
|
||||||
return Interface.objects.filter(machine__in=Machine.objects.filter(user=self))
|
return Interface.objects.filter(machine__in=Machine.objects.filter(user=self))
|
||||||
|
|
||||||
|
def set_user_password(self, password):
|
||||||
|
self.set_password(password)
|
||||||
|
self.pwd_ntlm = hashNT(password)
|
||||||
|
return
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.pseudo
|
return self.pseudo
|
||||||
|
|
||||||
|
|
|
@ -65,11 +65,7 @@ def form(ctx, template, request):
|
||||||
|
|
||||||
def password_change_action(u_form, user, request, req=False):
|
def password_change_action(u_form, user, request, req=False):
|
||||||
""" Fonction qui effectue le changeemnt de mdp bdd"""
|
""" Fonction qui effectue le changeemnt de mdp bdd"""
|
||||||
if u_form.cleaned_data['passwd1'] != u_form.cleaned_data['passwd2']:
|
user.set_user_password(u_form.cleaned_data['passwd1'])
|
||||||
messages.error(request, "Les 2 mots de passe différent")
|
|
||||||
return form({'userform': u_form}, 'users/user.html', request)
|
|
||||||
user.set_password(u_form.cleaned_data['passwd1'])
|
|
||||||
user.pwd_ntlm = hashNT(u_form.cleaned_data['passwd1'])
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
with transaction.atomic(), reversion.create_revision():
|
||||||
user.save()
|
user.save()
|
||||||
reversion.set_comment("Réinitialisation du mot de passe")
|
reversion.set_comment("Réinitialisation du mot de passe")
|
||||||
|
|
Loading…
Reference in a new issue