Commit d27f632c authored by gab's avatar gab

added email validatior for ateneo emails

parent fb455254
......@@ -20,7 +20,19 @@ class CustomUserCreationForm(UserCreationForm):
class Meta:
model = CustomUser
fields = ["email", "first_name", "last_name", "password1", "password2"]
fields = ["email", "password1", "password2", "first_name", "last_name", "role", "bio"]
# This method runs automatically when forms are submitted, the email is an ateneo email address
def clean_email(self):
data = self.cleaned_data['email']
if "@ateneo.edu" not in data and "@student.ateneo.edu" not in data and "@alumni.ateneo.edu" not in data:
raise forms.ValidationError("Must be an ateneo email address")
return data
# class CustomUserCreationForm(forms.ModelForm):
# email = forms.EmailField(widget=forms.EmailInput(attrs={'autofocus': True}))
# password = forms.CharField(widget=PasswordInput())
# class CustomUserChangeForm(UserChangeForm):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment