Skip to content

Commit 9a837d7

Browse files
committed
🚨 SASL: add_authenticator warns on reassignment (🚧 ???)
The question is: do we even want to this?
1 parent 5dc3f1d commit 9a837d7

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
@@ -64,7 +64,7 @@ def names; @authenticators.keys end
6464
# When only a single argument is given, the authenticator class will be
6565
# lazily loaded from <tt>Net::IMAP::SASL::#{name}Authenticator</tt> (case is
6666
# preserved and non-alphanumeric characters are removed..
67-
def add_authenticator(name, authenticator = nil)
67+
def add_authenticator(name, authenticator = nil, warn_overwrite: true)
6868
key = -name.to_s.upcase.tr(?_, ?-)
6969
authenticator ||= begin
7070
class_name = "#{name.gsub(/[^a-zA-Z0-9]/, "")}Authenticator".to_sym
@@ -74,6 +74,11 @@ def add_authenticator(name, authenticator = nil)
7474
auth_class.new(*creds, **props, &block)
7575
}
7676
end
77+
if warn_overwrite && (original = @authenticators[key])
78+
warn("%p: replacing existing %p authenticator: %p" % [
79+
self, key, original
80+
], uplevel: 1)
81+
end
7782
@authenticators[key] = authenticator
7883
end
7984

0 commit comments

Comments
 (0)