# TL2 welkomstbericht wordt elke keer verzonden bij SSO-login

**URL:** https://meta.discourse.org/t/tl2-welcome-message-sent-every-time-on-sso-login/172747
**Category:** Bug
**Created:** [9 december 2020 om 13:17 UTC](https://meta.discourse.org/t/tl2-welcome-message-sent-every-time-on-sso-login/172747 "2020-12-09T13:17:06Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [9 december 2020 om 13:17 UTC](https://meta.discourse.org/t/tl2-welcome-message-sent-every-time-on-sso-login/172747/1 "2020-12-09T13:17:06Z")

</div>

The following is happening:

Some users are getting the TL2 welcome notification (“we promoted you up a trust level”) on every login.

This happens under the following circumstances:

- SSO login is enabled where Discourse is the SSO client
- “Sync User Data” is enabled in WP-Discourse so it issues a `sync_sso` call every time the user logs into Wordpress
- `sync_sso` is setting a group that has a `grant_trust_level` which is lower than the current trust level of the user

This causes the trust levels for the user to be [recalculated from the ground up](https://github.com/discourse/discourse/blob/8ff9cdf390a4cc0587a8a3269fb7db9f8ee279a1/lib/promotion.rb#L122) and the welcome message to be sent every time.

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [4 januari 2022 om 07:17 UTC](https://meta.discourse.org/t/tl2-welcome-message-sent-every-time-on-sso-login/172747/9 "2022-01-04T07:17:12Z")

</div>

Hey there,

Thanks for sharing this bug! I’ve attempted to reproduce this bug but am not able to do so locally, here’s what my setup looks like:

* * *

(Wordpress)

- Set up wordpress user “Steaky” with email [steaky@cat.com](mailto:steaky@cat.com)
- add `wpdc_custom_sso_params` to set `cats` group to all users who sign in with `$params['groups'] = 'cats'; `

(Discourse)

- Create a user “Steaky” with email [steaky@cat.com](mailto:steaky@cat.com)
- Make Steaky `trust_level_3` legitimately (not locked)
- create group “cats” and set “Trust level automatically granted to members" to 2 for “cats”

Wordpress & Discourse connected 👌 also ☑ Sync user data.

(Discourse)

- log Steaky in, gets redirected to Wordpress and signs in, redirected back to Discourse
- (confirm that “cats” is set to Steaky)
- Steaky does not see welcome message

^ repeat above with `SiteSetting.discourse_connect_overrides_groups`, same result.

* * *

I suspect you’ve got a more detailed setup going on. It would be great if you could share more details about the setup of your affected users:

- Which other “[Discourse Connect](https://meta.discourse.org/t/13045?silent=true)” site settings do you have turned on?
- Are your affected users separately joining groups which may grant them certain trust levels?
- Are your affected users trust level locked? What kind of groups are they in?
- any other information that would be useful

Thanks!

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [4 januari 2022 om 08:16 UTC](https://meta.discourse.org/t/tl2-welcome-message-sent-every-time-on-sso-login/172747/10 "2022-01-04T08:16:59Z")

</div>

This bug is over one year old and in the meanwhile the client moved away from Discourse, so I cannot fully reproduce this anymore. However, I always take extensive notes so I even have record of the SSO payloads from back then. I am unable to inspect any other settings and/or try to repro on that exact instance though.

Back to my notes. What happened was a bit different from what you are doing. The SSO was passing an empty groups field (just `groups=`). But the users in question were members of another group, unknown to the SSO provider, which was forcing its members to TL2.

Additionally, the TL2 and TL3 welcome messages act differently as far as I recall, so you might have to use TL2 instead of TL3 if you attempt to reproduce this.

So to reproduce, I _think_ you need to do the following: (note that I introduced a second group)

(Wordpress)

- Set up wordpress user “Steaky” with email [steaky@cat.com](mailto:steaky@cat.com)
- add `wpdc_custom_sso_params` to set `dogs` group to all users who sign in with `$params['groups'] = 'dogs'; `

(Discourse)

- Create a user “Steaky” with email [steaky@cat.com](mailto:steaky@cat.com)
- Make Steaky `trust_level_1` legitimately (not locked)
- create group “cats” and “dogs” and set “Trust level automatically granted to members" to 2 for “cats”
- make Steaky member of group `cats`

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [19 januari 2022 om 07:28 UTC](https://meta.discourse.org/t/tl2-welcome-message-sent-every-time-on-sso-login/172747/11 "2022-01-19T07:28:46Z")

</div>

Have you been able to look into this issue any further?

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [19 januari 2022 om 08:51 UTC](https://meta.discourse.org/t/tl2-welcome-message-sent-every-time-on-sso-login/172747/12 "2022-01-19T08:51:59Z")

</div>

I’ve paused exploring that bug since my last response, but I’ve read and I’m appreciative of your notes! Quite incredible that you’ve got such a nice log of it. It’s still on my plate and I’ll be getting back to it soon, so thank you for checking in. 😃
