From 4b6a5f08faaae9264d1d35a394a4f35b455f1477 Mon Sep 17 00:00:00 2001 From: Natalie Tay Date: Thu, 27 Oct 2022 14:59:27 +0800 Subject: [PATCH] FIX: Allow users already in automatic groups to log in (#18771) --- app/models/discourse_connect.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/discourse_connect.rb b/app/models/discourse_connect.rb index fcdae32a4ff..ff256985858 100644 --- a/app/models/discourse_connect.rb +++ b/app/models/discourse_connect.rb @@ -406,8 +406,12 @@ class DiscourseConnect < DiscourseConnectBase def add_user_to_groups(user, groups) groups.each do |group| - GroupUser.create!(user_id: user.id, group_id: group.id) - GroupActionLogger.new(Discourse.system_user, group).log_add_user_to_group(user) + begin + GroupUser.create!(user_id: user.id, group_id: group.id) + GroupActionLogger.new(Discourse.system_user, group).log_add_user_to_group(user) + rescue Exception => e + Discourse.warn_exception(e, message: "User already in group") + end end end