Jump to content

Rules for usernames


suntrop
 Share

Recommended Posts

I need to import a list of users my client sends me. He wants to know what rules make a valid username. Sounds easy, but I need to make it bulletproof, when I tell my client, because he sends a lot of print letters with those usernames :-)

When I look at the name (aka username) filed it says:

Any combination of letters (a-z), numbers (0-9), dashes or underscores (no spaces).

As I think, those are pagenames and thus the sanitizer->pageName() is applied? This one says something different:

Page names by default support lowercase ASCII letters, digits, underscore, hyphen and period.

Usernames with periods apparently are ok. ASCII letters, however, sounds a bit ambiguous. @ or $ is in some manner a letter too. Perhaps I am wrong, but haven't studied english linguistic :-) And I think it only counts for the 128-ASCII table, not the extended one.

Seriously, I don't want to make it more complicated than it needs to be, but the docs made me think of it. Thanks!

  • Like 1
Link to comment
Share on other sites

Usernames are also sanitized in real time via JS - try adding an uppercase letter or a $ or @ and they will be converted/removed as soon as you unfocus the field.

I agree that when adding a user or normal page (both are effectively the same) it should note that periods are allowed.

OT a little - if you are adding users by a batch import, be sure to check out the Create Users Batcher action in the AdminActions module.

  • Like 1
Link to comment
Share on other sites

Thanks for your quick help.

Since I need to import the CSV via API, I wouldn't just trust the backend/JS. Other parts (like password, I think) don't match the UI rules.

And I need to create other related pages and more in the same run. Anyway, your module is on my list :-) Thanks!

Link to comment
Share on other sites

14 minutes ago, suntrop said:

Since I need to import the CSV via API, I wouldn't just trust the backend/JS

Not suggesting to trust it, just using it to give you a quick idea of what happens with various characters.

15 minutes ago, suntrop said:

And I need to create other related pages and more in the same run.

Depending on how you are doing things regarding the password, you might find these useful for automatic password generation and emailing the user with their username and temporary password:

http://modules.processwire.com/modules/email-new-user/
http://modules.processwire.com/modules/password-force-change/

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...