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,19 +81,21 @@ class DiscourseSingleSignOn < SingleSignOn
|
|||
private
|
||||
|
||||
def match_email_or_create_user(ip_address)
|
||||
user = User.find_by_email(email)
|
||||
unless user = User.find_by_email(email)
|
||||
try_name = name.presence
|
||||
try_username = username.presence
|
||||
|
||||
try_name = name.blank? ? nil : name
|
||||
try_username = username.blank? ? nil : username
|
||||
user_params = {
|
||||
email: email,
|
||||
name: try_name || User.suggest_name(try_username || email),
|
||||
username: UserNameSuggester.suggest(try_username || try_name || email),
|
||||
ip_address: ip_address
|
||||
}
|
||||
|
||||
user_params = {
|
||||
email: email,
|
||||
name: try_name || User.suggest_name(try_username || email),
|
||||
username: UserNameSuggester.suggest(try_username || try_name || email),
|
||||
ip_address: ip_address
|
||||
}
|
||||
user = User.create!(user_params)
|
||||
end
|
||||
|
||||
if user || user = User.create!(user_params)
|
||||
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