# "Login by email" switches to incorrect strings when "hide email address" activated

**URL:** https://meta.discourse.org/t/login-by-email-switches-to-incorrect-strings-when-hide-email-address-activated/143432
**Category:** Bug
**Created:** [March 5, 2020, 6:07pm UTC](https://meta.discourse.org/t/login-by-email-switches-to-incorrect-strings-when-hide-email-address-activated/143432 "2020-03-05T18:07:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [March 5, 2020, 6:07pm UTC](https://meta.discourse.org/t/login-by-email-switches-to-incorrect-strings-when-hide-email-address-activated/143432/1 "2020-03-05T18:07:36Z")

</div>

# Reproduce:

1. Enable the site setting `hide email address taken`, which is normally disabled, and described as _“Don’t inform users that an account exists with a given email address during signup and from the forgot password form.”_

2. From a new browser session, attempt to log in 📧 with email, and supply an invalid username, such as **codinghorror**.

# Expected behavior

The error message text from one of the following strings apppears, not divulging the existince or non-existence of an account.

**js.email\_login.complete\_email:**

> If an account matches **[codinghorror@example.com](mailto:codinghorror@example.com)**, you should receive an email with a login link shortly.

**js.email\_login.complete\_username:**

> If an account matches **codinghorror** , you should receive an email with a login link shortly.

# Actual behavior

The error message text incorrectly indicates that there was a positive match, even when there was no match.

**js.email\_login.complete\_email\_found:**

> We found an account that matches **[codinghorror@example.com](mailto:codinghorror@example.com)**, you should receive an email with a login link shortly.

**js.email\_login.complete\_username\_found:**

> We found an account that matches the username **codinghorror** , you should receive an email with a login link shortly.

# Commentary

Although this works correctly for the “reset password” process, it seems the same logic should hold through with the login by email workflow.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [March 6, 2020, 6:28pm UTC](https://meta.discourse.org/t/login-by-email-switches-to-incorrect-strings-when-hide-email-address-activated/143432/2 "2020-03-06T18:28:06Z")

</div>

> [@downey](#):
>
> Don’t inform users that an account exists with a given email address during signup and from the forgot password form.”

I do not see this as a bug. The behavior is exactly as described above.

But if we have the other copy we should be using it in this scenario @eviltrout

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [March 6, 2020, 6:45pm UTC](https://meta.discourse.org/t/login-by-email-switches-to-incorrect-strings-when-hide-email-address-activated/143432/3 "2020-03-06T18:45:31Z")

</div>

> [@codinghorror](#):
>
> But if we have the other copy we should be using it in this scenario @eviltrout

Sorry if this was confusing. The bug as perceived, is that when (and **only** when) `hide email address taken` is set active, **and** non-matching values are entered for email-based login:

Instead of displaying the intentionally-ambiguous **js.email\_login.complete\_email** and **js.email\_login.complete\_username** strings, it instead (mistakenly) displays a false positive using strings **js.email\_login.complete\_email\_found** and **js.email\_login.complete\_username\_found**.

If the site setting is disabled (default) it correctly displays “no match found” strings.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [March 9, 2020, 4:54pm UTC](https://meta.discourse.org/t/login-by-email-switches-to-incorrect-strings-when-hide-email-address-activated/143432/4 "2020-03-09T16:54:55Z")

</div>

This should fix it:

[https://github.com/discourse/discourse/commit/ec21a15fa7234b8274b5b137afdd6dff78cf52a9](https://github.com/discourse/discourse/commit/ec21a15fa7234b8274b5b137afdd6dff78cf52a9)

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [March 9, 2020, 5:28pm UTC](https://meta.discourse.org/t/login-by-email-switches-to-incorrect-strings-when-hide-email-address-activated/143432/5 "2020-03-09T17:28:50Z")

</div>

> [@eviltrout](#):
>
> This should fix it

Yes, this looks correct now. Thanks! 🏆

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [March 10, 2020, 8:23am UTC](https://meta.discourse.org/t/login-by-email-switches-to-incorrect-strings-when-hide-email-address-activated/143432/6 "2020-03-10T08:23:53Z")

</div>


