FIX: Don't attempt to add user again to a group when syncing groups via SSO (#18772)

This commit fixes a regression introduced in 8979adc where under certain conditions the groups syncing logic in Discourse Connect would try to add users to groups they're already members of and cause errors when users try to sign in using Discourse Connect.
This commit is contained in:
Osama Sayegh
2022-10-28 13:27:12 +03:00
committed by GitHub
parent fa5f43e7c0
commit e120c94236
2 changed files with 21 additions and 13 deletions

View File

@ -206,7 +206,7 @@ RSpec.describe DiscourseConnect do
expect(group2.usernames).to eq("")
group1.add(user)
group1.save
group1.save!
sso.lookup_or_create_user(ip_address)
expect(group1.usernames).to eq("")
@ -216,6 +216,16 @@ RSpec.describe DiscourseConnect do
sso.lookup_or_create_user(ip_address)
expect(group1.usernames).to eq("")
expect(group2.usernames).to eq("")
group1.add(user)
group1.save!
group2.add(user)
group2.save!
sso.groups = "#{group1.name},badname,trust_level_4"
sso.lookup_or_create_user(ip_address)
expect(group1.usernames).to eq(user.username)
expect(group2.usernames).to eq("")
end
it "can specify groups" do