suntrop Posted August 29, 2017 Share Posted August 29, 2017 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! 1 Link to comment Share on other sites More sharing options...
adrian Posted August 29, 2017 Share Posted August 29, 2017 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. 1 Link to comment Share on other sites More sharing options...
suntrop Posted August 29, 2017 Author Share Posted August 29, 2017 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 More sharing options...
adrian Posted August 29, 2017 Share Posted August 29, 2017 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/ 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now