mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-25 16:33:47 +00:00
Patch user password
This commit is contained in:
parent
30b933d8ac
commit
6fd865bbd2
2 changed files with 10 additions and 5 deletions
|
@ -27,7 +27,7 @@ def makeSecret(password):
|
||||||
|
|
||||||
def hashNT(password):
|
def hashNT(password):
|
||||||
hash = hashlib.new('md4', password.encode('utf-16le')).digest()
|
hash = hashlib.new('md4', password.encode('utf-16le')).digest()
|
||||||
return binascii.hexlify(hash)
|
return binascii.hexlify(hash).upper()
|
||||||
|
|
||||||
|
|
||||||
def checkPassword(challenge_password, password):
|
def checkPassword(challenge_password, password):
|
||||||
|
|
|
@ -3,20 +3,25 @@
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.auth.forms import ReadOnlyPasswordHashField
|
from django.contrib.auth.forms import ReadOnlyPasswordHashField
|
||||||
|
from django.core.validators import MinLengthValidator
|
||||||
|
|
||||||
from .models import User, ServiceUser, get_admin_right
|
from .models import User, ServiceUser, get_admin_right
|
||||||
|
|
||||||
|
def validate_password(value):
|
||||||
|
if not (any(x.isupper() for x in value) and any(x.islower() for x in value)):
|
||||||
|
raise forms.ValidationError("Le mot de passe doit contenir au moins une majuscule, une minuscule et un chiffre")
|
||||||
|
return value
|
||||||
|
|
||||||
class PassForm(forms.Form):
|
class PassForm(forms.Form):
|
||||||
passwd1 = forms.CharField(label=u'Nouveau mot de passe', max_length=255, widget=forms.PasswordInput)
|
passwd1 = forms.CharField(label=u'Nouveau mot de passe', max_length=255, validators=[MinLengthValidator(8), validate_password], widget=forms.PasswordInput)
|
||||||
passwd2 = forms.CharField(label=u'Saisir à nouveau le mot de passe', max_length=255, widget=forms.PasswordInput)
|
passwd2 = forms.CharField(label=u'Saisir à nouveau le mot de passe', max_length=255, validators=[MinLengthValidator(8), validate_password], widget=forms.PasswordInput)
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
fields, plus a repeated password."""
|
fields, plus a repeated password."""
|
||||||
password1 = forms.CharField(label='Password', widget=forms.PasswordInput, min_length=8, max_length=255)
|
password1 = forms.CharField(label='Password', widget=forms.PasswordInput, validators=[MinLengthValidator(8), validate_password], max_length=255)
|
||||||
password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput, min_length=8, max_length=255)
|
password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput, validators=[MinLengthValidator(8), validate_password], max_length=255)
|
||||||
is_admin = forms.BooleanField(label='is admin')
|
is_admin = forms.BooleanField(label='is admin')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
Loading…
Reference in a new issue