OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Better error messages
Oliver Güntheraa6a06657892
diff --git a/app/controllers/omni_auth_login_controller.rb b/app/controllers/omni_auth_login_controller.rbindex 74dad853055..bfc027e2289 100644--- a/app/controllers/omni_auth_login_controller.rb+++ b/app/controllers/omni_auth_login_controller.rb@@ -55,12 +55,22 @@ class OmniAuthLoginController < ApplicationControllerenddef failure- logger.warn(params[:message]) if params[:message]- show_error I18n.t(:error_external_authentication_failed)+ log_omniauth_failure+ show_error I18n.t(:error_external_authentication_failed, message: omniauth_error)endprivate+ def log_omniauth_failure+ type = request.env["omniauth.error.type"] || "internal"+ logger.warn "OmniAuth authentication failed (Error #{type}): #{omniauth_error}"+ end++ def omniauth_error+ message = request.env["omniauth.error"] || request.env["omniauth.error.type"] || request.env["omniauth.error.message"]+ message&.to_s || "Unknown error"+ end+def redirect_omniauth_register_modal(user, auth_hash)# Store a timestamp so we can later make sure that authentication information can# only be reused for a short time.diff --git a/config/locales/en.yml b/config/locales/en.ymlindex cd25d99c6a0..f124410b7ef 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1748,7 +1748,7 @@ en:Can't rename "%{old_name}" to "%{new_name}" due to a conflict in the resulting menu itemwith the existing menu item "%{existing_caption}" (%{existing_identifier}).- error_external_authentication_failed: "An error occurred during external authentication. Please try again."+ error_external_authentication_failed: "An error occurred during external authentication: %{message}"error_attribute_not_highlightable: "Attribute(s) not highlightable: %{attributes}"events:diff --git a/modules/auth_saml/spec/requests/saml_provider_callback_spec.rb b/modules/auth_saml/spec/requests/saml_provider_callback_spec.rbindex 7af02bacc02..a78a8a3a05c 100644--- a/modules/auth_saml/spec/requests/saml_provider_callback_spec.rb+++ b/modules/auth_saml/spec/requests/saml_provider_callback_spec.rb@@ -29,7 +29,9 @@require "spec_helper"require "rack/test"-RSpec.describe "SAML provider callback", with_ee: %i[openid_providers] do+RSpec.describe "SAML provider callback",+ type: :rails_request,+ with_ee: %i[openid_providers] doinclude Rack::Test::Methodsinclude API::V3::Utilities::PathHelper@@ -79,10 +81,11 @@ RSpec.describe "SAML provider callback", with_ee: %i[openid_providers] do}end- shared_examples "request fails" do+ shared_examples "request fails" do |message|it "redirects to the failure page" doexpect(subject.status).to eq(302)- expect(subject.headers["Location"]).to eq("/auth/failure?message=invalid_ticket&strategy=saml")+ follow_redirect!+ expect(last_response.body).to have_text messageendend@@ -98,13 +101,13 @@ RSpec.describe "SAML provider callback", with_ee: %i[openid_providers] doendend- it_behaves_like "request fails"+ it_behaves_like "request fails", "Current time is earlier than NotBefore condition"endcontext "with an invalid fingerprint" dolet(:fingerprint) { "invalid" }- it_behaves_like "request fails"+ it_behaves_like "request fails", "Fingerprint mismatch"endcontext "with a RelayState present" dodiff --git a/spec/controllers/concerns/omniauth_login_spec.rb b/spec/controllers/concerns/omniauth_login_spec.rbindex b7ff40174c3..c5519cfd7b6 100644--- a/spec/controllers/concerns/omniauth_login_spec.rb+++ b/spec/controllers/concerns/omniauth_login_spec.rb@@ -484,9 +484,10 @@ RSpec.describe OmniAuthLoginController, :skip_2fa_stage do # rubocop:disable RSpit "logs a warn message" doallow(Rails.logger).to receive(:warn)- post :failure, params: { message: "invalid_credentials" }+ request.env["omniauth.error"] = "invalid_credentials"+ post :failure- expect(Rails.logger).to have_received(:warn).with("invalid_credentials")+ expect(Rails.logger).to have_received(:warn).with(/invalid_credentials/)endendend