correct issue where groups was never being blanked

This commit is contained in:
Sam 2018-04-10 15:30:18 +10:00
parent 5925a581db
commit fe37ce165d
2 changed files with 10 additions and 1 deletions

View File

@ -114,7 +114,11 @@ class DiscourseSingleSignOn < SingleSignOn
.where('group_id IN (SELECT id FROM groups WHERE NOT automatic)')
.where(user_id: user.id)
group_users.where('group_id NOT IN (?)', ids).destroy_all
delete_group_users = group_users
if ids.length > 0
delete_group_users = group_users.where('group_id NOT IN (?)', ids)
end
delete_group_users.destroy_all
ids -= group_users.where('group_id IN (?)', ids).pluck(:group_id)

View File

@ -147,6 +147,11 @@ describe DiscourseSingleSignOn do
sso.lookup_or_create_user(ip_address)
expect(group1.usernames).to eq("")
expect(group2.usernames).to eq(user.username)
sso.groups = "badname,trust_level_4"
sso.lookup_or_create_user(ip_address)
expect(group1.usernames).to eq("")
expect(group2.usernames).to eq("")
end
it "can specify groups" do