# Users are not added to the moderators groups when registering with SSO

**URL:** https://meta.discourse.org/t/users-are-not-added-to-the-moderators-groups-when-registering-with-sso/40165
**Category:** Bug
**Tags:** sso, discourseconnect
**Created:** [February 25, 2016, 3:30pm UTC](https://meta.discourse.org/t/users-are-not-added-to-the-moderators-groups-when-registering-with-sso/40165 "2016-02-25T15:30:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [February 25, 2016, 3:30pm UTC](https://meta.discourse.org/t/users-are-not-added-to-the-moderators-groups-when-registering-with-sso/40165/1 "2016-02-25T15:30:07Z")

</div>

**Steps to reproduce:**

1. Have SSO set up.
2. Let a new user sign in, and specify that he is a moderator in the payload.

**Expected results:**

The users has exactly the same permissions as if he signed up and was instantly manually awarded moderator permissions.

**Actual results:**

The user is given the moderator flag, but is not added to the `staff` or `moderator` groups. This means that he cannot access categories requiring these permissions.

Here’s a screenshot of the user settings:

 ![](https://global.discourse-cdn.com/meta/original/3X/f/2/f2e0f8685bf553c64d30e0c84c2881c8cdf5a24f.png)

It looks like hitting Refresh on `/admin/groups/automatic` fixes this for already created users.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [May 12, 2016, 4:55pm UTC](https://meta.discourse.org/t/users-are-not-added-to-the-moderators-groups-when-registering-with-sso/40165/2 "2016-05-12T16:55:39Z")

</div>

The issue is still there in version `v1.6.0.beta4 +161` :sadpanda:

The same effect occurs if an existing user is given moderator privileges by another SSO sign-in.

After snooping around in the code, could this be because SSO simply sets the flag and saves the user…

> <https://github.com/discourse/discourse/blob/19ca08857fba1b74669af0568e1abe9932b84866/app/models/discourse_single_sign_on.rb#L76>

…while the proper “grant moderation” action…

> <https://github.com/discourse/discourse/blob/be3a5a56ccc284b352aa65080fc6b955f73cc72a/app/models/concerns/roleable.rb#L20>

…runs this refresh?

> <https://github.com/discourse/discourse/blob/be3a5a56ccc284b352aa65080fc6b955f73cc72a/app/models/concerns/roleable.rb#L38>

---

<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: [May 17, 2016, 7:31am UTC](https://meta.discourse.org/t/users-are-not-added-to-the-moderators-groups-when-registering-with-sso/40165/3 "2016-05-17T07:31:59Z")

</div>

Fixed per:

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

Thanks!

---

<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: [May 17, 2016, 7:32am UTC](https://meta.discourse.org/t/users-are-not-added-to-the-moderators-groups-when-registering-with-sso/40165/4 "2016-05-17T07:32:02Z")

</div>


