# 根据电子邮件域自动将用户添加到组

**URL:** <https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157>\
**Category:** SSO\
**Created:** [2020年四月7日 16:58 UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157 "2020-04-07T16:58:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hollyw](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@hollyw](https://meta.discourse.org/u/hollyw)\
**Post date:** [2020年四月7日 16:58 UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/1 "2020-04-07T16:58:15Z")

</div>

在我们的论坛上，我们创建了一个针对特定电子邮件域名的用户自定义组。我的理解是，使用该域名注册的新用户会自动被添加到该组。然而，该功能似乎并未自动运行。目前，我必须进入“组 \> 成员资格”并点击“保存更改”，才能使最新一批新用户被添加到该组中，否则他们似乎不会被加入。

这是否是预期行为？另外，我想补充说明，我们使用的是单点登录（SSO），因此我不确定这是否会影响该功能。

---

<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:** [2020年四月7日 22:41 UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/2 "2020-04-07T22:41:24Z")

</div>

@sam 这与最近的其他报告一样，这些规则不一致。

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2020年四月7日 22:45 UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/3 "2020-04-07T22:45:19Z")

</div>

看起来是单点登录（SSO）的 bug

能否确认您正在使用 [https://meta.discourse.org/t/official-single-sign-on-for-discourse-sso/13045？](https://meta.discourse.org/t/official-single-sign-on-for-discourse-sso/13045%EF%BC%9F)

---

<div class="post-metadata">

**Author:** ![hollyw](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@hollyw](https://meta.discourse.org/u/hollyw)\
**Post date:** [2020年四月7日 22:54 UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/4 "2020-04-07T22:54:27Z")

</div>

是的，我们使用的是 Discourse 的官方单点登录（SSO）。

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2020年四月8日 06:36 UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/6 "2020-04-08T06:36:38Z")

</div>

我认为这就是那个 bug。

当你通过 SSO 更新邮箱时，由于启用了 `sso_overrides_email`，自动组加入功能未能生效。

该功能在初次创建用户时是有效的。

注意，整个“回溯”概念非常令人困惑，我们或许应该直接将其移除。我建议你确保始终设置“将相同的邮箱域名规则应用于添加已注册的用户”，我们即将移除该选项。

> <https://github.com/discourse/discourse/commit/b824898f614d21c43a78fec30481757341106d5a>
>
> Previously we were only updating group membership when a user record was
> first c…reated in an SSO setting.
> 
> This corrects it so we also update it if SSO changes the email

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2020年四月8日 14:30 UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/7 "2020-04-08T14:30:29Z")

</div>

我建议通过单点登录（SSO）管理这些组，并在用户登录时自动推送。

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2024年五月3日 05:33 UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/8 "2024-05-03T05:33:34Z")

</div>



---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [2024年五月3日 08:57 UTC](https://meta.discourse.org/t/automatic-addition-of-users-to-group-based-on-email-domain/147157/9 "2024-05-03T08:57:17Z")

</div>


