Skip to content

Commit eae8e04

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

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
@@ -68,7 +68,7 @@ def names; @authenticators.keys end
6868
# When only a single argument is given, the authenticator class will be
6969
# lazily loaded from <tt>Net::IMAP::SASL::#{name}Authenticator</tt> (case is
7070
# preserved and non-alphanumeric characters are removed..
71-
def add_authenticator(name, authenticator = nil)
71+
def add_authenticator(name, authenticator = nil, warn_overwrite: true)
7272
authenticator ||= begin
7373
class_name = "#{name.gsub(/[^a-zA-Z0-9]/, "")}Authenticator".to_sym
7474
auth_class = nil
@@ -78,6 +78,11 @@ def add_authenticator(name, authenticator = nil)
7878
}
7979
end
8080
key = Authenticators.normalize_name(name)
81+
if warn_overwrite && (original = @authenticators[key])
82+
warn("%p: replacing existing %p authenticator: %p" % [
83+
self, key, original
84+
], uplevel: 1)
85+
end
8186
@authenticators[key] = authenticator
8287
end
8388

0 commit comments

Comments
 (0)