diff --git a/.rubocop.yml b/.rubocop.yml index 821c3902e520..d45f3c613d7b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -248,6 +248,7 @@ RSpec/DescribeMethod: # to match the exact file name RSpec/SpecFilePathFormat: CustomTransform: + OpenIDConnect: openid_connect OAuthClients: oauth_clients IgnoreMethods: true diff --git a/app/components/op_primer/border_box_table_component.html.erb b/app/components/op_primer/border_box_table_component.html.erb index 293aa2d79ed5..01cbc672c596 100644 --- a/app/components/op_primer/border_box_table_component.html.erb +++ b/app/components/op_primer/border_box_table_component.html.erb @@ -46,11 +46,11 @@ See COPYRIGHT and LICENSE files for more details. if rows.empty? component.with_row(scheme: :default) { render_blank_slate } - end - - rows.each do |row| - component.with_row(scheme: :default) do - render(row_class.new(row:, table: self)) + else + rows.each do |row| + component.with_row(scheme: :default) do + render(row_class.new(row:, table: self)) + end end end end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index ea6bcf6d4b10..4947c77dd9c4 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -72,7 +72,7 @@ def password_change_not_possible(user) if user.ldap_auth_source user.ldap_auth_source.name else - user.authentication_provider + user.human_authentication_provider end open_project_headers "Type" => "Account" diff --git a/app/models/auth_provider.rb b/app/models/auth_provider.rb index 69d724c0faed..8a38a4894b02 100644 --- a/app/models/auth_provider.rb +++ b/app/models/auth_provider.rb @@ -32,10 +32,20 @@ class AuthProvider < ApplicationRecord validates :display_name, presence: true validates :display_name, uniqueness: true + after_destroy :unset_direct_provider + def self.slug_fragment raise NotImplementedError end + def user_count + @user_count ||= User.where("identity_url LIKE ?", "#{slug}%").count + end + + def human_type + raise NotImplementedError + end + def auth_url root_url = OpenProject::StaticRouting::StaticUrlHelpers.new.root_url URI.join(root_url, "auth/#{slug}/").to_s @@ -44,4 +54,12 @@ def auth_url def callback_url URI.join(auth_url, "callback").to_s end + + protected + + def unset_direct_provider + if Setting.omniauth_direct_login_provider == slug + Setting.omniauth_direct_login_provider = "" + end + end end diff --git a/app/models/user.rb b/app/models/user.rb index 11749506f856..4b3d33175723 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -308,7 +308,12 @@ def name(formatter = nil) def authentication_provider return if identity_url.blank? - identity_url.split(":", 2).first.titleize + identity_url.split(":", 2).first + end + + # Return user's authentication provider for display + def human_authentication_provider + authentication_provider&.titleize end ## diff --git a/app/views/admin/settings/authentication_settings/show.html.erb b/app/views/admin/settings/authentication_settings/show.html.erb index 8943b42aee49..cca0e8c6d325 100644 --- a/app/views/admin/settings/authentication_settings/show.html.erb +++ b/app/views/admin/settings/authentication_settings/show.html.erb @@ -57,6 +57,27 @@ See COPYRIGHT and LICENSE files for more details. <%= render Settings::NumericSettingComponent.new("invitation_expiration_days", unit: "days") %> +
+ +