# 合并用户失败

**URL:** https://meta.discourse.org/t/merging-user-failing/172390
**Category:** Bug
**Tags:** merge-user
**Created:** [2020年十二月6日 10:41 UTC](https://meta.discourse.org/t/merging-user-failing/172390 "2020-12-06T10:41:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Alexander\_Wright](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexander_wright/32/119518_2.png) [@Alexander\_Wright](https://meta.discourse.org/u/Alexander_Wright)
#### Post date: [2020年十二月6日 10:41 UTC](https://meta.discourse.org/t/merging-user-failing/172390/1 "2020-12-06T10:41:19Z")

</div>

我在尝试合并两个用户账户时遇到了错误。

我的 SSO 提供商曾返回不同的 ID，导致少数用户出现了重复账户。

SSO 问题现已修复，我正在尝试合并这些重复账户。

但在执行管理员合并功能时，系统弹出一个错误提示框，日志中显示了以下内容。账户并未被合并。

> **错误日志**
>
> ```plaintext
> 消息（报告了 2 份副本）
> 
> NoMethodError（nil:NilClass 未定义方法 `email'）
> app/models/user.rb:1243:in `email'
> app/services/user_merger.rb:8:in `initialize'
> app/controllers/admin/users_controller.rb:507:in `new'
> app/controllers/admin/users_controller.rb:507:in `merge'
> app/controllers/application_controller.rb:358:in `block in with_resolved_locale'
> app/controllers/application_controller.rb:358:in `with_resolved_locale'
> lib/middleware/omniauth_bypass_middleware.rb:68:in `call'
> lib/content_security_policy/middleware.rb:12:in `call'
> lib/middleware/anonymous_cache.rb:354:in `call'
> config/initializers/100-quiet_logger.rb:23:in `call'
> config/initializers/100-silence_logger.rb:31:in `call'
> lib/middleware/enforce_hostname.rb:22:in `call'
> lib/middleware/request_tracker.rb:176:in `call'
> 
> 回溯
> 
> app/models/user.rb:1243:in `email'
> app/services/user_merger.rb:8:in `initialize'
> app/controllers/admin/users_controller.rb:507:in `new'
> app/controllers/admin/users_controller.rb:507:in `merge'
> actionpack (6.0.3.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
> actionpack (6.0.3.3) lib/abstract_controller/base.rb:195:in `process_action'
> actionpack (6.0.3.3) lib/action_controller/metal/rendering.rb:30:in `process_action'
> actionpack (6.0.3.3) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
> activesupport (6.0.3.3) lib/active_support/callbacks.rb:112:in `block in run_callbacks'
> app/controllers/application_controller.rb:358:in `block in with_resolved_locale'
> 
> 环境
> 
> HTTP 主机：discourse.camra.org.uk
> 
> ```

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [2020年十二月9日 14:24 UTC](https://meta.discourse.org/t/merging-user-failing/172390/4 "2020-12-09T14:24:53Z")

</div>

看起来您尝试合并的用户没有主电子邮件地址。这应该可以解决：

> <https://github.com/discourse/discourse/pull/11446>

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [2020年十二月10日 22:32 UTC](https://meta.discourse.org/t/merging-user-failing/172390/5 "2020-12-10T22:32:22Z")

</div>


