diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index bfaf5d60d9..e62ac4814a 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -31,7 +31,7 @@ require 'concerns/omniauth_login' class AccountController < ApplicationController include CustomFieldsHelper - include OmniauthLogin + include Concerns::OmniauthLogin # prevents login action to be filtered by check_if_login_required application scope filter skip_before_filter :check_if_login_required @@ -44,8 +44,8 @@ class AccountController < ApplicationController def login if User.current.logged? redirect_to home_url - elsif OmniauthLogin.direct_login? - redirect_to OmniauthLogin.direct_login_provider_url + elsif Concerns::OmniauthLogin.direct_login? + redirect_to Concerns::OmniauthLogin.direct_login_provider_url elsif request.post? authenticate_user end diff --git a/app/controllers/concerns/omniauth_login.rb b/app/controllers/concerns/omniauth_login.rb index 7344499dae..d422609140 100644 --- a/app/controllers/concerns/omniauth_login.rb +++ b/app/controllers/concerns/omniauth_login.rb @@ -1,6 +1,6 @@ ## # Intended to be used by the AccountController to handle omniauth logins -module OmniauthLogin +module Concerns::OmniauthLogin def omniauth_login auth_hash = request.env['omniauth.auth'] diff --git a/lib/redmine/menu_manager/top_menu_helper.rb b/lib/redmine/menu_manager/top_menu_helper.rb index 948c3868b2..3eab818eb4 100644 --- a/lib/redmine/menu_manager/top_menu_helper.rb +++ b/lib/redmine/menu_manager/top_menu_helper.rb @@ -83,12 +83,10 @@ module Redmine::MenuManager::TopMenuHelper def render_user_top_menu_node(items = menu_items_for(:account_menu)) if User.current.logged? render_user_drop_down items + elsif Concerns::OmniauthLogin.direct_login? + render_direct_login else - if OmniauthLogin.direct_login? - render_direct_login - else - render_login_drop_down - end + render_login_drop_down end end diff --git a/spec/controllers/account_controller_spec.rb b/spec/controllers/account_controller_spec.rb index cc929a4cc6..838dbf900a 100644 --- a/spec/controllers/account_controller_spec.rb +++ b/spec/controllers/account_controller_spec.rb @@ -158,7 +158,7 @@ describe AccountController do describe '#login with omniauth_direct_login enabled' do before do - OmniauthLogin.stub(:direct_login_provider).and_return('some_provider') + Concerns::OmniauthLogin.stub(:direct_login_provider).and_return('some_provider') end describe 'GET' do diff --git a/spec/views/layouts/base.html.erb_spec.rb b/spec/views/layouts/base.html.erb_spec.rb index 91572357bb..8536d20614 100644 --- a/spec/views/layouts/base.html.erb_spec.rb +++ b/spec/views/layouts/base.html.erb_spec.rb @@ -56,7 +56,7 @@ describe "layouts/base" do context 'with omni_auth_direct_login enabled' do before do - expect(OmniauthLogin).to receive(:direct_login_provider).and_return('some_provider') + expect(Concerns::OmniauthLogin).to receive(:direct_login_provider).and_return('some_provider') render end