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
[36294] Show authentication header only when any partial matches (#9044)
Oliver Günther935cd02d33c9
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rbindex 061420b9621..08cb7bac79c 100644--- a/app/controllers/users_controller.rb+++ b/app/controllers/users_controller.rb@@ -97,7 +97,6 @@ class UsersController < ApplicationControllerdef new@user = User.new(language: Setting.default_language,mail_notification: Setting.default_notification_option)- @auth_sources = AuthSource.allenddef create@@ -115,8 +114,6 @@ class UsersController < ApplicationControllerendendelse- @auth_sources = AuthSource.all-respond_to do |format|format.html { render action: 'new' }end@@ -124,7 +121,6 @@ class UsersController < ApplicationControllerenddef edit- @auth_sources = AuthSource.all@membership ||= Member.new@individual_principal = @userend@@ -167,7 +163,6 @@ class UsersController < ApplicationControllerendendelse- @auth_sources = AuthSource.all@membership ||= Member.new# Clear password input@user = call.resultdiff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rbindex 29faa65813e..3fbbad95450 100644--- a/app/helpers/users_helper.rb+++ b/app/helpers/users_helper.rb@@ -142,4 +142,8 @@ module UsersHelperdef user_name(user)user ? user.name : I18n.t('user.deleted')end++ def can_users_have_auth_source?+ AuthSource.any? && !OpenProject::Configuration.disable_password_login?+ endenddiff --git a/app/views/users/form/authentication/_auth_source.html.erb b/app/views/users/form/authentication/_auth_source.html.erbindex e75d986cb21..53f54184ff7 100644--- a/app/views/users/form/authentication/_auth_source.html.erb+++ b/app/views/users/form/authentication/_auth_source.html.erb@@ -1,7 +1,12 @@-<% unless @auth_sources.empty? || OpenProject::Configuration.disable_password_login? %>+<% if can_users_have_auth_source? %><div class="form--field">- <% sources = ([[t(:label_internal), ""]] + @auth_sources.collect { |a| [a.name, a.id] }) %>- <%= f.select :auth_source_id, sources, label: :'activerecord.attributes.user.auth_source', container_class: '-middle' %>+ <%= f.collection_select :auth_source_id,+ AuthSource.all,+ :id,+ :name,+ label: :'activerecord.attributes.user.auth_source',+ container_class: '-middle',+ include_blank: t(:label_internal) %></div><div class="form--field" id="new_user_login" style="display: none;">diff --git a/app/views/users/form/authentication/_form.html.erb b/app/views/users/form/authentication/_form.html.erbindex 4b1586f83ba..e941ee47f26 100644--- a/app/views/users/form/authentication/_form.html.erb+++ b/app/views/users/form/authentication/_form.html.erb@@ -1,5 +1,8 @@<section class="form--section">- <h3 class="form--section-title"><%=t(:label_authentication)%></h3>+ <% if current_user.admin? || can_users_have_auth_source? || @user.uses_external_authentication? %>+ <h3 class="form--section-title"><%=t(:label_authentication)%></h3>+ <% end %>+<% if @user.uses_external_authentication? %><%= render partial: 'users/form/authentication/external', locals: { f: f } %><% else %>