Memberships
This commit is contained in:
Executable
+26
@@ -0,0 +1,26 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.password_validation import validate_password
|
||||
|
||||
|
||||
class RegistrationForm(forms.Form):
|
||||
uid = forms.RegexField(regex=r"^[a-z][a-z0-9._-]{2,47}$", max_length=48, label="Username", help_text="3–48 lowercase letters, numbers, dots, underscores or hyphens. Start with a letter.")
|
||||
email = forms.EmailField(max_length=254)
|
||||
|
||||
def clean_email(self):
|
||||
return self.cleaned_data["email"].strip().casefold()
|
||||
|
||||
|
||||
class PasswordForm(forms.Form):
|
||||
password = forms.CharField(max_length=1024, widget=forms.PasswordInput(attrs={"autocomplete": "new-password"}), label="Password", help_text="At least 12 characters. Stored only in OpenLDAP, never on this website.")
|
||||
confirm_password = forms.CharField(max_length=1024, widget=forms.PasswordInput(attrs={"autocomplete": "new-password"}), label="Confirm password")
|
||||
|
||||
def clean_password(self):
|
||||
password = self.cleaned_data["password"]
|
||||
validate_password(password)
|
||||
return password
|
||||
|
||||
def clean(self):
|
||||
data = super().clean()
|
||||
if data.get("password") != data.get("confirm_password"):
|
||||
self.add_error("confirm_password", "Passwords must match.")
|
||||
return data
|
||||
Reference in New Issue
Block a user