Unverified Commit e05abcf3 authored by Gabriel Geraldo's avatar Gabriel Geraldo Committed by GitHub

Merge pull request #1 from avraiel/user_auth

created a branch for user_auth, merging so that future user_auth changes will have bootstrap designs
parents 14ebfa3d d27f632c
......@@ -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):
......
......@@ -3,11 +3,19 @@ from django.contrib.auth.models import AbstractUser
# Create your models here.
class CustomUser(AbstractUser):
ROLE_CHOICES = [
("STUDENT", "Student"),
("ORG", "Organization"),
("ALUMNI", "Alumni"),
("FACULTY", "Faculty"),
]
username = None
email = models.EmailField(unique=True, db_index=True)
first_name = models.CharField(blank=False, max_length=150)
last_name = models.CharField(blank=False, max_length=150)
role = models.CharField(max_length=7, blank=False, choices=ROLE_CHOICES)
bio = models.TextField(blank=True, max_length=150)
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
......
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