Added password validators
This commit is contained in:
parent
8bacf4f2bf
commit
30867ad279
|
@ -2,6 +2,7 @@ from django import forms
|
||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
|
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
from django.contrib.auth.password_validation import validate_password
|
||||||
|
|
||||||
class UserCreateForm(ModelForm):
|
class UserCreateForm(ModelForm):
|
||||||
password1 = forms.CharField(label='Passwort')
|
password1 = forms.CharField(label='Passwort')
|
||||||
|
@ -11,6 +12,13 @@ class UserCreateForm(ModelForm):
|
||||||
model = get_user_model()
|
model = get_user_model()
|
||||||
fields = ['username', 'email', 'twitter', 'github']
|
fields = ['username', 'email', 'twitter', 'github']
|
||||||
|
|
||||||
|
def clean_password1(self):
|
||||||
|
password1 = self.cleaned_data.get("password1")
|
||||||
|
|
||||||
|
validate_password(password1)
|
||||||
|
|
||||||
|
return password1
|
||||||
|
|
||||||
|
|
||||||
def clean_password2(self):
|
def clean_password2(self):
|
||||||
password1 = self.cleaned_data.get("password1")
|
password1 = self.cleaned_data.get("password1")
|
||||||
|
|
|
@ -15,7 +15,6 @@ class UserCreateView(CreateView):
|
||||||
form_class = UserCreateForm
|
form_class = UserCreateForm
|
||||||
template_name = 'users/signup.html'
|
template_name = 'users/signup.html'
|
||||||
|
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse('send_confirmation', kwargs={'user_id' : self.object.pk})
|
return reverse('send_confirmation', kwargs={'user_id' : self.object.pk})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue