Skip to content

Commit efcfcf4

Browse files
committed
🚨 SASL: add_authenticator warns on reassignment (🚧 ???)
The question is: do we even want to this?
1 parent 8adc2cc commit efcfcf4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/net/imap/sasl/authenticators.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def names; @authenticators.keys end
6565
# When only a single argument is given, the authenticator class will be
6666
# lazily loaded from <tt>Net::IMAP::SASL::#{name}Authenticator</tt> (case is
6767
# preserved and non-alphanumeric characters are removed..
68-
def add_authenticator(name, authenticator = nil)
68+
def add_authenticator(name, authenticator = nil, warn_overwrite: true)
6969
key = name.upcase.to_sym
7070
authenticator ||= begin
7171
class_name = "#{name.gsub(/[^a-zA-Z0-9]/, "")}Authenticator".to_sym
@@ -75,6 +75,11 @@ def add_authenticator(name, authenticator = nil)
7575
auth_class.new(*creds, **props, &block)
7676
}
7777
end
78+
if warn_overwrite && (original = @authenticators[key])
79+
warn("%p: replacing existing %p authenticator: %p" % [
80+
self, key, original
81+
], uplevel: 1)
82+
end
7883
@authenticators[key] = authenticator
7984
end
8085

0 commit comments

Comments
 (0)