# Error when trying to save duplicate email

**URL:** https://meta.discourse.org/t/error-when-trying-to-save-duplicate-email/38368
**Category:** Bug
**Created:** [January 23, 2016, 5:11am UTC](https://meta.discourse.org/t/error-when-trying-to-save-duplicate-email/38368 "2016-01-23T05:11:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![watchmanmonitor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/watchmanmonitor/32/430970_2.png) [@watchmanmonitor](https://meta.discourse.org/u/watchmanmonitor)
#### Post date: [January 23, 2016, 5:11am UTC](https://meta.discourse.org/t/error-when-trying-to-save-duplicate-email/38368/1 "2016-01-23T05:11:19Z")

</div>

This error was logged on a fully up to date discourse:

Discourse::InvalidParameters (email) /var/www/discourse/app/controllers/users\_controller.rb:487:in `change\_email’

Repro:

- Allow emails to be changed
- visit a user’s profile
- enter in a duplicate email
- Get a normal warning

this will be logged:

> <https://gist.github.com/YesThatAllen/0dfc52427d3042245d6f>

---

<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: [January 23, 2016, 5:56am UTC](https://meta.discourse.org/t/error-when-trying-to-save-duplicate-email/38368/2 "2016-01-23T05:56:44Z")

</div>

Hmm can you repro this @techapj?

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [January 23, 2016, 8:28am UTC](https://meta.discourse.org/t/error-when-trying-to-save-duplicate-email/38368/3 "2016-01-23T08:28:40Z")

</div>

Yes, I was able to repro this. I made two fixes:

- `change` button will be disabled when the email is duplicate (i.e. same as user’s current email).

- In case the new email user provided is already in use by another user than instead of serving 500 (Internal Server Error), 422 error will be served with proper error message.

* * *

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

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [January 23, 2016, 8:28am UTC](https://meta.discourse.org/t/error-when-trying-to-save-duplicate-email/38368/4 "2016-01-23T08:28:51Z")

</div>


