course-management-platform
course-management-platform copied to clipboard
Improve Admin Login UI to Accept Email Address Instead of Username
Issue Title: Improve Admin Login UI to Accept Email Address Instead of Username
Description: Currently, the admin login interface does not accept usernames, leading to confusion for users. To enhance usability and clarity, it's advisable to modify the UI to accept email address instead of username.
Below are potential changes to the code:
Proposed Changes:
-
Update the custom user model Before:
class CustomUser(AbstractUser): ROLE_CHOICES = ( ('student', 'Student'), ('instructor', 'Instructor'), ) role = models.CharField(max_length=10, choices=ROLE_CHOICES, default='student')After:
class CustomUser(AbstractUser): ROLE_CHOICES = ( ('student', 'Student'), ('instructor', 'Instructor'), ) role = models.CharField(max_length=10, choices=ROLE_CHOICES, default='student') USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['username']Warning: Upon making the proposed changes, the following warning is encountered:
WARNINGS: accounts.CustomUser: (auth.W004) 'CustomUser.email' is named as the 'USERNAME_FIELD', but it is not unique. HINT: Ensure that your authentication backend(s) can handle non-unique usernames.SOLUTION:
email = models.EmailField(_("email address"), max_length=255, unique=True)
Hi @alexeygrigorev, Please let me know your thoughts on this one.
Also, feel free to close the issue if it's not that important.
we don't intend to have that many admins actually, but if it's a simple change, why not