DEV: Remove deprecated AuthProvider#enabled_setting= (#27081)

AuthProvider#enabled_setting=, used primarily by plugins, has been deprecated since version 2.9, in favour of Authenticator#enabled?. This PR confirms we are seeing no more usage and removes the method.
This commit is contained in:
Ted Johansson 2024-05-20 18:10:15 +08:00 committed by GitHub
parent 9302187ca4
commit 32aaf2e8d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 0 additions and 72 deletions

View File

@ -17,7 +17,6 @@ class Auth::AuthProvider
frame_height
pretty_name_setting
title_setting
enabled_setting
full_screen_login
full_screen_login_setting
custom_url
@ -28,14 +27,6 @@ class Auth::AuthProvider
attr_accessor(*auth_attributes)
def enabled_setting=(val)
Discourse.deprecate(
"(#{authenticator.name}) enabled_setting is deprecated. Please define authenticator.enabled? instead",
drop_from: "2.9.0",
)
@enabled_setting = val
end
def background_color=(val)
Discourse.deprecate(
"(#{authenticator.name}) background_color is no longer functional. Please use CSS instead",

View File

@ -791,25 +791,6 @@ class Plugin::Instance
provider.public_send("#{sym}=", opts.delete(sym)) if opts.has_key?(sym)
end
begin
provider.authenticator.enabled?
rescue NotImplementedError
provider
.authenticator
.define_singleton_method(:enabled?) do
Discourse.deprecate(
"#{provider.authenticator.class.name} should define an `enabled?` function. Patching for now.",
drop_from: "2.9.0",
)
return SiteSetting.get(provider.enabled_setting) if provider.enabled_setting
Discourse.deprecate(
"#{provider.authenticator.class.name} has not defined an enabled_setting. Defaulting to true.",
drop_from: "2.9.0",
)
true
end
end
DiscoursePluginRegistry.register_auth_provider(provider)
end
end

View File

@ -324,49 +324,6 @@ TEXT
end
end
it "patches the enabled? function for auth_providers if not defined" do
SimpleAuthenticator =
Class.new(Auth::Authenticator) do
def name
"my_authenticator"
end
end
plugin = Plugin::Instance.new
# lets piggy back on another boolean setting, so we don't dirty our SiteSetting object
SiteSetting.enable_badges = false
# No enabled_site_setting
authenticator = SimpleAuthenticator.new
plugin.auth_provider(authenticator: authenticator)
plugin.notify_after_initialize
expect(authenticator.enabled?).to eq(true)
# With enabled site setting
plugin = Plugin::Instance.new
authenticator = SimpleAuthenticator.new
plugin.auth_provider(enabled_setting: "enable_badges", authenticator: authenticator)
plugin.notify_after_initialize
expect(authenticator.enabled?).to eq(false)
# Defines own method
plugin = Plugin::Instance.new
SiteSetting.enable_badges = true
authenticator =
Class
.new(SimpleAuthenticator) do
def enabled?
false
end
end
.new
plugin.auth_provider(enabled_setting: "enable_badges", authenticator: authenticator)
plugin.notify_after_initialize
expect(authenticator.enabled?).to eq(false)
end
describe "#activate!" do
before do
# lets piggy back on another boolean setting, so we don't dirty our SiteSetting object

View File

@ -50,7 +50,6 @@ RSpec.describe Users::OmniauthCallbacksController do
end
.new
provider.enabled_setting = "ubuntu_login_enabled"
provider
end