Username requirements

Hi all

I see when registering accounts on my Open edX instance there is the following requirement for self-registration:

Usernames can only contain letters (A-Z, a-z), numerals (0-9), underscores (_), and hyphens (-).

This requirement basically eliminates name.surname options for self registration, but as a Django admin I can create users with a DOT in the username. How can I expand self-reg to support dots in the username?

Majority of the other services that I run use name(dot)surname so I’d like to keep this consistent for my staff wherever possible.

Thank you :slight_smile:

Hello there Joel! I hope you’re doing great :stuck_out_tongue_winking_eye:

You can try adding to your lms.yml a regex expression that includes dots, I tested this:

FEATURES:
    ENABLE_UNICODE_USERNAME: true
...

USERNAME_REGEX_PARTIAL: '[\w._+-]+'

You can change the regex exp according to your needs. And the result was

3 Likes

Ah nice, that setting automatically gets wrapped in ^___$: edx-platform/registration_form.py at db32ff2cdf678fa8edd12c9da76a76eef0478614 · openedx/edx-platform · GitHub

2 Likes

Awesome, thanks @mgmdi :slight_smile:

Interestingly when I put both
ENABLE_UNICODE_USERNAME: true
USERNAME_REGEX_PARTIAL: ‘[\w._±]+’
into the configs then I get Internal Server Error on my browser.

I then removed USERNAME_REGEX_PARTIAL and somehow that seemed to work just fine on it’s own and now I can register email addresses with dots :smiley:
Thank you very much

Looks like as of latest on master, the regex includes a period by default: edx-platform/common.py at 0157518a9cf0d8d92e3640d4d3160682b7bdd1b6 · openedx/edx-platform · GitHub (and also space and @).

1 Like