diff --git a/.env_sample b/.env_sample index 4acfc4528..7a5e06992 100644 --- a/.env_sample +++ b/.env_sample @@ -1,5 +1,6 @@ SECRET_KEY=change-this-secret +# Database DB_HOST=db DB_NAME=postgres DB_USERNAME=postgres diff --git a/src/apps/profiles/forms.py b/src/apps/profiles/forms.py index a959acb8d..c2b0b43cc 100644 --- a/src/apps/profiles/forms.py +++ b/src/apps/profiles/forms.py @@ -4,8 +4,22 @@ class SignUpForm(UserCreationForm): - email = forms.EmailField(max_length=254, help_text='Required. Inform a valid email address.') + + email = forms.EmailField( + max_length=254, help_text="Required. Inform a valid email address." + ) + + def clean_username(self): + data = self.cleaned_data["username"] + if not data.islower(): + raise forms.ValidationError("Usernames should be in lowercase") + if not data.isalnum(): + raise forms.ValidationError( + "Usernames should not contain special characters." + ) + return data class Meta: + model = User - fields = ('username', 'email', 'password1', 'password2', ) + fields = ("username", "email", "password1", "password2")