From 30867ad279829e0c92059349dd7a375e849c66a0 Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Tue, 2 May 2017 19:03:56 +0200 Subject: [PATCH] Added password validators --- users/forms.py | 8 ++++++++ users/views.py | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/users/forms.py b/users/forms.py index b75a82e..54775a5 100644 --- a/users/forms.py +++ b/users/forms.py @@ -2,6 +2,7 @@ from django import forms from django.forms import ModelForm from django.contrib.auth import get_user_model +from django.contrib.auth.password_validation import validate_password class UserCreateForm(ModelForm): password1 = forms.CharField(label='Passwort') @@ -11,6 +12,13 @@ class UserCreateForm(ModelForm): model = get_user_model() fields = ['username', 'email', 'twitter', 'github'] + def clean_password1(self): + password1 = self.cleaned_data.get("password1") + + validate_password(password1) + + return password1 + def clean_password2(self): password1 = self.cleaned_data.get("password1") diff --git a/users/views.py b/users/views.py index 6534c29..1d3aa0f 100644 --- a/users/views.py +++ b/users/views.py @@ -15,7 +15,6 @@ class UserCreateView(CreateView): form_class = UserCreateForm template_name = 'users/signup.html' - def get_success_url(self): return reverse('send_confirmation', kwargs={'user_id' : self.object.pk})