[ZendTo] email vs username REGEX

Jules Field Jules at Zend.To
Wed May 1 10:00:54 BST 2019


Most sites have users login using just their username rather than email 
So my default supplied regex for the username is more restrictive than 
the one for the email address, as you want to keep it as tight as you can.

If you want to allow an email address for the username, then the 
simplest solution is to just copy the regex from 'validEmailRegexp' into 
the value for 'usernameRegexp' in preferences.php.

That's one of the reasons I have those 2 specified in a config file 
rather than hard-wired. :-)


On 30/04/2019 23:11, Guy Bertrand via ZendTo wrote:
> Hi all,
> I’m using the AD authenticator.  Users are login in using their email 
> addresses, which are checked against our AD servers.  All is good.
> Almost…I have one user who has an apostrophe in his email/account 
> name, and cannot login.
> I noticed that in the preferences.php file, the REGEX for username and 
> email address do not match.  I’ve looked at the code, and I was trying 
> to find (unsucessfully) if there is some type of filtering or 
> conversion being done, and the actual lookup against AD uses a modifed 
> usernameRegexp instead of the raw username as the user typed in the 
> login screen.  The usernameRegexp does not seem to allow the apostrophe.
> I’m still looking, but if anybody has a suggestion or an explanation 
> why the username cannot use an apostrophe, I’d appreciate it.  Or do I 
> simply change the username regex to allow for the apostrophe?
> Regards,
> Guy
> // Regular expression defining a valid username for the Login page.
> // Usually no need to change this.
> 'usernameRegexp'    => '/^([a-zA-Z0-9][a-zA-Z0-9\_\.\-\@\\\]*)$/i',
> // regular expression defining a valid email address for anyone.
> // Usually no need to change this.
> // Must look like /^(user)\@(domain)$/
> 'validEmailRegexp' => 
> '/^([a-zA-Z0-9][a-zA-Z0-9\.\_\-\+\&\']*)\@([a-zA-Z0-9][a-zA-Z0-9\_\-\.]+)$/i',
> ------------------------------------------------------------------------
> Please consider the environment before printing or forwarding this 
> email. If you do print this email, please recycle the paper.
> This email message may contain confidential, proprietary and/or 
> privileged information. It is intended only for the use of the 
> intended recipient(s). If you have received it in error, please 
> immediately advise the sender by reply email and then delete this 
> email message. Any disclosure, copying, distribution or use of the 
> information contained in this email message to or by anyone other than 
> the intended recipient is strictly prohibited. Any views expressed in 
> this message are those of the individual sender, except where the 
> sender specifically states them to be the views of Exela Technologies, 
> Inc. or its subsidiaries.
> This email does not constitute an agreement to conduct transactions by 
> electronic means and does not create any legally binding contract or 
> enforceable obligation against Exela in the absence of a fully signed 
> written agreement.
> _______________________________________________
> ZendTo mailing list
> ZendTo at zend.to
> http://jul.es/mailman/listinfo/zendto



'A committee is a group of the unwilling, chosen from the unfit,
  to do the unnecessary.' - Anon

Twitter: @JulesFM

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jul.es/pipermail/zendto/attachments/20190501/5bda9495/attachment.html>

More information about the ZendTo mailing list