Skip to content

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

Fix failure message

Oliver Günther982ce8d25fb8
diff --git a/app/controllers/omni_auth_login_controller.rb b/app/controllers/omni_auth_login_controller.rb
index bfc027e2289..62e8569c492 100644
--- a/app/controllers/omni_auth_login_controller.rb
+++ b/app/controllers/omni_auth_login_controller.rb
@@ -56,7 +56,7 @@ class OmniAuthLoginController < ApplicationController
def failure
log_omniauth_failure
- show_error I18n.t(:error_external_authentication_failed, message: omniauth_error)
+ show_error I18n.t(:error_external_authentication_failed_message, message: omniauth_error)
end
private
diff --git a/config/locales/en.yml b/config/locales/en.yml
index f124410b7ef..ed270549ad5 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 item
with the existing menu item "%{existing_caption}" (%{existing_identifier}).
- error_external_authentication_failed: "An error occurred during external authentication: %{message}"
+ error_external_authentication_failed_message: "An error occurred during external authentication: %{message}"
error_attribute_not_highlightable: "Attribute(s) not highlightable: %{attributes}"
events:
diff --git a/spec/controllers/concerns/omniauth_login_spec.rb b/spec/controllers/omni_auth_login_controller_spec.rb
similarity index 98%
rename from spec/controllers/concerns/omniauth_login_spec.rb
rename to spec/controllers/omni_auth_login_controller_spec.rb
index c5519cfd7b6..c894b27c17e 100644
--- a/spec/controllers/concerns/omniauth_login_spec.rb
+++ b/spec/controllers/omni_auth_login_controller_spec.rb
@@ -29,7 +29,7 @@
require "spec_helper"
# Concern is included into AccountController and depends on methods available there
-RSpec.describe OmniAuthLoginController, :skip_2fa_stage do # rubocop:disable RSpec/SpecFilePathFormat
+RSpec.describe OmniAuthLoginController, :skip_2fa_stage do
let(:omniauth_strategy) { double("Google Strategy", name: "google") } # rubocop:disable RSpec/VerifiedDoubles
let(:omniauth_hash) do
OmniAuth::AuthHash.new(
@@ -477,9 +477,12 @@ RSpec.describe OmniAuthLoginController, :skip_2fa_stage do # rubocop:disable RSp
end
describe "Error occurs during authentication" do
- it "redirects to login page" do
+ it "display the error" do
+ request.env["omniauth.error"] = "invalid_credentials"
post :failure
+
expect(response).to redirect_to signin_path
+ expect(flash[:error]).to include "invalid_credentials"
end
it "logs a warn message" do
diff --git a/spec/features/auth/omniauth_spec.rb b/spec/features/auth/omniauth_spec.rb
index c592662e983..fff0dc28c5b 100644
--- a/spec/features/auth/omniauth_spec.rb
+++ b/spec/features/auth/omniauth_spec.rb
@@ -248,7 +248,7 @@ RSpec.describe "Omniauth authentication" do
OmniAuth::FailureEndpoint.new(env).redirect_to_failure
end
visit login_path
- expect(page).to have_content(I18n.t(:error_external_authentication_failed))
+ expect(page).to have_content(I18n.t(:error_external_authentication_failed_message, message: "Unknown error"))
if defined? instructions
expect(page).to have_content instructions