0

Quick question.

On my site, users have entered their username with capitalized case or mixed upper or lower cases during registration. Now when the Login, they forget that write everything lower cased and ofcourse that doesn't work making things difficult for me.

so my humble question is, how do I validate the login regardless of case?

Thanks a lot.

1

There are no modules that I know of at this time that provides this functionality. It can be done, however, by writing a custom module.

I suggest that you look at LoginToboggan as a model for how to write your own module. The basic flow is this:

  1. LoginToboggan allows users to log in using either their username or email address. Drupal, by default, does not support logging in with an email address, so LT does a hook_form_alter() to add a function to the login form's #validate.
  2. The Validate function, logintoboggan_user_login_validate() searches for an email address that matches the one provided by the user. If it is found, then LT provides the username to the form programmatically.
  3. Because the username is provided during the #validate step, the form flow continues and processes the username which was retrieved by LT, and the user is logged in.

Your solution would follow a very similar flow, but instead of checking for an email address, you would check against username. The LT function uses a LOWER() SQL function to recognize differences in capitalization in the email; you will do the same, except with usernames.

One addition that you may have to make is that, if you allow users to register themselves on your site and pick their own usernames, you may need to ensure that the selected username does not collide with a capitalized version (e.g, Drupal may allow a username mrawesome and MrAwesome because they are different, but you should disallow the latter because they are viewed as equivalents within the confines of your system).

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.