Skip to content

Commit

Permalink
🚨 SASL: add_authenticator warns on reassignment (🚧 ???)
Browse files Browse the repository at this point in the history
The question is: do we even want to this?
  • Loading branch information
nevans committed Sep 21, 2023
1 parent 7a089d9 commit 52c19d6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/net/imap/sasl/authenticators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def names; @authenticators.keys end
# When only a single argument is given, the authenticator class will be
# lazily loaded from <tt>Net::IMAP::SASL::#{name}Authenticator</tt> (case is
# preserved and non-alphanumeric characters are removed..
def add_authenticator(name, authenticator = nil)
def add_authenticator(name, authenticator = nil, warn_overwrite: true)
key = name.upcase.to_sym
authenticator ||= begin
class_name = "#{name.gsub(/[^a-zA-Z0-9]/, "")}Authenticator".to_sym
Expand All @@ -75,6 +75,11 @@ def add_authenticator(name, authenticator = nil)
auth_class.new(*creds, **props, &block)
}
end
if warn_overwrite && (original = @authenticators[key])
warn("%p: replacing existing %p authenticator: %p" % [
self, key, original
], uplevel: 1)
end
@authenticators[key] = authenticator
end

Expand Down

0 comments on commit 52c19d6

Please sign in to comment.