course-management-platform icon indicating copy to clipboard operation
course-management-platform copied to clipboard

Improve Admin Login UI to Accept Email Address Instead of Username

Open bhimrazy opened this issue 1 year ago • 2 comments

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:

  1. 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)
    
    

image

bhimrazy avatar Mar 26 '24 11:03 bhimrazy

Hi @alexeygrigorev, Please let me know your thoughts on this one.

Also, feel free to close the issue if it's not that important.

bhimrazy avatar Mar 26 '24 11:03 bhimrazy

we don't intend to have that many admins actually, but if it's a simple change, why not

alexeygrigorev avatar Mar 26 '24 15:03 alexeygrigorev