mirror of
https://github.com/discourse/discourse.git
synced 2025-04-15 17:32:56 +08:00
DEV: Add logging and rescue when user already exists and connecting via DiscourseConnect (#22833)
This is happening because despite the user already existing in the forum, the `SingleSignOnRecord` doesn't exist and "require_activation" is set on the provider, causing us to skip looking for the email, and resulting in us creating a new User then seeing Validation failed: Primary email has already been taken when DiscourseConnect is attempting to make a new account.
This commit is contained in:
parent
ad05924bdf
commit
173de8afe6
@ -267,7 +267,16 @@ class DiscourseConnect < DiscourseConnectBase
|
|||||||
ReviewableUser.set_approved_fields!(user, Discourse.system_user)
|
ReviewableUser.set_approved_fields!(user, Discourse.system_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
user.save!
|
begin
|
||||||
|
user.save!
|
||||||
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
|
if SiteSetting.verbose_discourse_connect_logging
|
||||||
|
Rails.logger.error(
|
||||||
|
"Verbose SSO log: User creation failed. External id: #{external_id}, New User (user_id: #{user.id}) Params: #{user_params} User Params: #{user.attributes} User Errors: #{user.errors.full_messages} Email: #{user.primary_email.attributes} Email Error: #{user.primary_email.errors.full_messages}",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
raise e
|
||||||
|
end
|
||||||
|
|
||||||
if SiteSetting.verbose_discourse_connect_logging
|
if SiteSetting.verbose_discourse_connect_logging
|
||||||
Rails.logger.warn(
|
Rails.logger.warn(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user