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:

1 Like

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

Hi @mgmdi

I do add ENABLE_UNICODE_USERNAME: true inside the lms.yml followed by tutor config save and automatically placed it inside config.yml after tutor config save and tutor images build openedz but the result is still the same I can’t register username with dots

Hello allen_luna,
What version are you using? Because from Quince to validate the user name field you can modify the regular expression from the constant:

INVALID_NAME_REGEX: /[-a-zA-Z0-9@:%.+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b([-a -zA-Z0-9()@:%+.~#?&//=]*)?/gi;

In the File
src/register/RegistrationFields/NameField/validator.js

1 Like

Yes the version I used is Quince, Thank you @Juan-Carlos you owe me a beer. hahaha

1 Like