better logs when an error happens in SSO
This commit is contained in:
parent
f7432d8ec9
commit
97c7b894ce
|
@ -117,7 +117,14 @@ class SessionController < ApplicationController
|
|||
SingleSignOn::ACCESSORS.each do |a|
|
||||
details[a] = sso.send(a)
|
||||
end
|
||||
Rails.logger.error "Failed to create or lookup user: #{e}\n\n#{details.map{|k,v| "#{k}: #{v}"}.join("\n")}"
|
||||
|
||||
message = "Failed to create or lookup user: #{e}."
|
||||
message << "\n\n" << "-" * 100
|
||||
message << details.map { |k,v| "#{k}: #{v}" }.join("\n")
|
||||
message << "\n\n" << "-" * 100
|
||||
message << e.backtrace.join("\n")
|
||||
|
||||
Rails.logger.error(message)
|
||||
|
||||
render text: I18n.t("sso.unknown_error"), status: 500
|
||||
end
|
||||
|
|
|
@ -81,10 +81,9 @@ class DiscourseSingleSignOn < SingleSignOn
|
|||
private
|
||||
|
||||
def match_email_or_create_user(ip_address)
|
||||
user = User.find_by_email(email)
|
||||
|
||||
try_name = name.blank? ? nil : name
|
||||
try_username = username.blank? ? nil : username
|
||||
unless user = User.find_by_email(email)
|
||||
try_name = name.presence
|
||||
try_username = username.presence
|
||||
|
||||
user_params = {
|
||||
email: email,
|
||||
|
@ -93,7 +92,10 @@ class DiscourseSingleSignOn < SingleSignOn
|
|||
ip_address: ip_address
|
||||
}
|
||||
|
||||
if user || user = User.create!(user_params)
|
||||
user = User.create!(user_params)
|
||||
end
|
||||
|
||||
if user
|
||||
if sso_record = user.single_sign_on_record
|
||||
sso_record.last_payload = unsigned_payload
|
||||
sso_record.external_id = external_id
|
||||
|
|
Loading…
Reference in New Issue