Skip to content

Commit 7b87669

Browse files
committed
🚨 SASL: add_authenticator warns on reassignment
1 parent a0ede93 commit 7b87669

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
@@ -60,7 +60,7 @@ def names; @authenticators.keys end
6060
# When only a single argument is given, the authenticator class will be
6161
# lazily loaded from <tt>Net::IMAP::SASL::#{name}Authenticator</tt> (case is
6262
# preserved and non-alphanumeric characters are removed..
63-
def add_authenticator(name, authenticator = nil)
63+
def add_authenticator(name, authenticator = nil, warn_overwrite: true)
6464
key = name.upcase.to_sym
6565
authenticator ||= begin
6666
class_name = "#{name.gsub(/[^a-zA-Z0-9]/, "")}Authenticator".to_sym
@@ -70,6 +70,11 @@ def add_authenticator(name, authenticator = nil)
7070
auth_class.new(*creds, **props, &block)
7171
}
7272
end
73+
if warn_overwrite && (original = @authenticators[key])
74+
warn("%p: replacing existing %p authenticator: %p" % [
75+
self, key, original
76+
], uplevel: 1)
77+
end
7378
@authenticators[key] = authenticator
7479
end
7580

0 commit comments

Comments
 (0)