# Change user's email without verification

**URL:** https://meta.discourse.org/t/change-users-email-without-verification/66602
**Category:** Self-hosting
**Tags:** rails-console
**Created:** [7월 21, 2017, 3:47오후 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602 "2017-07-21T15:47:04Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![carlokok](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carlokok/32/115951_2.png) [@carlokok](https://meta.discourse.org/u/carlokok)
#### Post date: [7월 21, 2017, 3:47오후 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602/1 "2017-07-21T15:47:04Z")

</div>

Maybe I’m missing something obvious, but I cannot find it. As an admin, can I change someone’s email address without them having to verify it?

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [7월 21, 2017, 7:18오후 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602/2 "2017-07-21T19:18:22Z")

</div>

Off-hand, I’d guess something like this would work:

```plaintext
cd /var/discourse
./launcher enter app
rails c
User.find_by(email: "chowder@mmmm.fooo").update(email: "bisque@soup.mmmm")
exit
exit

```

That’s console access, obviously.

---

<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: [7월 21, 2017, 11:15오후 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602/3 "2017-07-21T23:15:41Z")

</div>

I vaguely recall another topic here about this exact situation; try some searches.

---

<div class="post-metadata">

### Author: ![JagWaugh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagwaugh/32/69335_2.png) [@JagWaugh](https://meta.discourse.org/u/JagWaugh)
#### Post date: [7월 22, 2017, 5:07오전 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602/4 "2017-07-22T05:07:40Z")

</div>

Try this, the verification mail goes out, but they don’t have to respond to it:

> [@Changing a user's email address when they can't access their account](https://meta.discourse.org/t/howto-change-a-users-email-when-they-cant-access-the-email-account/56322):
>
> bookmark This guide explains how to change a user’s email address when they can’t access their original email account and have forgotten their password. person_raising_hand Required user level: Administrator There are situations where you may need to change a user’s email address on their behalf, such as when they no longer have access to the email associated with their account. This often occurs after migrating from a preexisting system where users logged in with a username and password…

Too late for me to edit that now, but it should be deactivate, change, reactivate iirc.

---

<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: [7월 22, 2017, 5:25오전 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602/5 "2017-07-22T05:25:01Z")

</div>

No problem I made it a wiki.

---

<div class="post-metadata">

### Author: ![skodali](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@skodali](https://meta.discourse.org/u/skodali)
#### Post date: [1월 9, 2018, 8:02오후 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602/6 "2018-01-09T20:02:14Z")

</div>

I am a new discourse user and I ran into the same issue. When I try the same approach (deactivate the user, update the email address, and then activate the user) it sending an email to confirm and it is only updating the email address after clicking the confirm email link. Is there a way to avoid this? I am using the API to do all the three actions.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [1월 10, 2018, 3:14오전 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602/7 "2018-01-10T03:14:19Z")

</div>

There has been a change in the way emails are stored in the database.

The following commands should work:

```plaintext
cd /var/discourse
sudo ./launcher enter app
rails c

UserEmail.find_by(email: "oid@example.com").update(email: "new@example.com")

```

---

<div class="post-metadata">

### Author: ![skodali](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@skodali](https://meta.discourse.org/u/skodali)
#### Post date: [1월 10, 2018, 3:15오후 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602/8 "2018-01-10T15:15:59Z")

</div>

This will work fine but I am trying to do this via API as I will have to update multiple email addresses on a daily basis. Is it possible to do this via API?

---

<div class="post-metadata">

### Author: ![Iceman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iceman/32/181309_2.png) [@Iceman](https://meta.discourse.org/u/Iceman)
#### Post date: [9월 11, 2020, 10:24오전 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602/10 "2020-09-11T10:24:09Z")

</div>

대규모 네크로맨시(Massive Necromancy)는 맞지만, 저는 유사한 문제를 겪고 있으며 검색 결과 이 게시글로 오게 되어 이 경험을 바탕으로 명령어를 업데이트하는 것이 관련이 있을 수 있습니다.

제 상황은 다음과 같습니다:

- 일부 사용자가 주요 이메일 주소를 변경하려고 시도했습니다.
- 그들은 작동하지 않았다고 주장합니다. 확인용 이메일은 받았지만 링크를 클릭하면 항상 "만료됨/작동 안 함"이라는 메시지가 표시됩니다.
- 저는 관리자(Admin) 권한으로 해당 이메일을 변경하러 가서 프로필을 편집하여 변경했습니다.
- 이제 주요 이메일은 “확인/검증 대기” 상태입니다.
- 사용자는 확인용 이메일을 전혀 받지 못합니다.
- 프로필에서 “검증/확인 이메일 재전송” 옵션을 아무리 많이 눌러도 이메일이 발송되지 않습니다(관리자/이메일 섹션에서 확인했는데, 해당 이메일에 대한 발신 기록이 없습니다. 아이러니하게도 "비밀번호 재설정 이메일"을 보내라고 클릭하면 그 이메일은 **발송** 됩니다).

문제는, 해당 사용자 중 누군가가 쿠키 등을 정리하면 계정에 다시 접근할 수 없게 된다는 점입니다(지금 실제로 일어나고 있습니다). 그래서 이렇게 시도해 보았습니다:

> [@schungx](#):
>
> 다음 명령어가 작동해야 합니다:
> 
> ```plaintext
> cd /var/discourse
> sudo ./launcher enter app
> rails c
> 
> UserEmail.find_by(email: "oid@example.com").update(email: "new@example.com")
> 
> ```

하지만 `NoMethodError: undefined method `update' for nil:NilClass` 오류가 발생합니다. 아마도 지난 2년 사이에 필드가 다시 변경되었을까요? 😛

어떤 도움도 환영합니다.

참고: 또한 이메일을 다른 것으로 변경하거나 원래 이메일로 되돌리려 하면, 이제 저(관리자)에게 "이 작업을 너무 많이 수행했습니다. 나중에 다시 시도해 주세요"라는 메시지가 표시됩니다. '나중’은 얼마나 뒤를 의미하며, 저는 한 번만 수행했는데 왜 관리자가 이메일 변경 시 속도 제한(rate limited)을 받는 것일까요? 아마 제가 무언가를 잘못해서 인지하지 못한 것 같습니다 :facepalm:

---

<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: [9월 11, 2020, 6:34오후 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602/11 "2020-09-11T18:34:49Z")

</div>

> [@Iceman](#):
>
> 그들은 작동하지 않는다고 주장합니다. 확인용 이메일은 받았는데 링크를 클릭하면 항상 “만료됨/작동하지 않음” 메시지가 나타난다고 합니다.

이메일 전송은 정상적으로 이루어지고 있으니, 서버 시간이 틀렸거나 부정확한 것일 수 있습니다. 서버 시간이 틀려 있으면 이러한 문제가 발생할 수 있습니다.

---

<div class="post-metadata">

### Author: ![mint\_saxon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mint_saxon/32/167253_2.png) [@mint\_saxon](https://meta.discourse.org/u/mint_saxon)
#### Post date: [8월 22, 2021, 11:50오후 UTC](https://meta.discourse.org/t/change-users-email-without-verification/66602/12 "2021-08-22T23:50:55Z")

</div>

> [@Iceman](#):
>
> 하지만 `NoMethodError: undefined method `update’ for nil:NilClass` 오류가 발생하고 있습니다. 혹시 지난 2년 사이에 필드가 다시 변경된 걸까요? 😛

저는 잘 작동했습니다! 이 문제를 여전히 겪고 계신 분이나 이 주제를 발견하신 다른 분들을 위해 😅, `UserEmail.find_by(email: "oid@example.com")`가 아무것도 반환하지 않으면 해당 오류가 발생할 것 같습니다. 이메일 주소가 정확히 일치하는지 한 번 더 확인해 보시는 것이 좋겠습니다.
