Case-insensitive email address on log-in?

Is there a way to make the log-in email address case-insensitive? Or, failing that, remind the user, on every log-in, that the email address is case-sensitive?

Here’s what happened:

  1. User created an account via desktop web browser, using all-lowercase email address.
  2. Confirmation email sent to iPhone. All subsequent attempts to deal with the email occurred on that device, not the desktop.
  3. On the iPhone, user clicked relevant links, and tried to log in, which required re-entry of email address. iPhone automatically capitalized one or more letters of the address. Since our email addresses are not case sensitive, this initially went completely unnoticed. When it caused the log-in to fail, the user blamed Anvil.
  4. Later log-in attempts on the iPhone succeeded, but only by physically interrupting the text entry, to erase and replace each uppercased letter with lowercase.

I’ve seen Android and dumb phones do the same thing. The keyboard “thinks” we’re entering names or sentences, instead of literal text, and so auto-capitalizes the 1st letter (and possibly later ones).

The same thing might be happening with the password field. If it is, we’d never see it was happening – the password field displays as blobs or asterisks. Attempts to log in on the same kind of device (desktop vs. mobile) where the password was first entered would succeed, but attempts on the opposite kind of device would mysteriously fail.

Though I suppose they could exist, I’ve never seen or used a case-sensitive email address. We receive emails regardless of the casing of the domain or the name.

1 Like

Hi Phil,

You’re right, this is a feature our standard login form doesn’t (yet) have. The good news is that you don’t have to wait for us - you can build your own!

If you’ve collected a user’s email and password yourself (eg with a pair of TextBoxes), you can attempt login by calling anvil.users.login_with_email(email, password). There’s nothing to stop you, eg, forcing the email address to lower-case before you send it. (You might also want to replace the signup form with your own form which also forces the email to lower-case before calling anvil.users.signup_with_email().)

See the API documentation for the full details, including how we signal errors, how to trigger a “reset password” email, and more. The Users service is heavily extensible - the idea is that we provide simple defaults, but let you modify it to work however you like :slight_smile:

1 Like

Thanks, Meredydd. As it happens, we’ve been debating building our own log-in page anyway, for other reasons. (#1: To provide each user with their own unique ID, e.g., for phone-in tech support purposes.) We’ll fold this requirement into the design.

2 Likes

Just to checking: the solution that anvil will do is to add .lower() after the email address in your base code at the time of saving registration email and logging in?
Thanks
Lucas

Correct! All email addresses will be stored (and checked) in lower-case. (So we don’t break any existing apps, we will also support exact-case match when the email address in the Users table is not lower-cased.)

This fix will be released early this coming week.

2 Likes

Hi Meredydd, just wanted to say that this “partial case-sensitivity” was really confusing to me. Wouldn’t it make sense to disable it for newly created apps? Or maybe add a hint box in the user service page?

1 Like