Skip to content

Commit 8660f24

Browse files
committed
♻️ Support keyword args for SASL PLAIN
1 parent 092299f commit 8660f24

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/net/imap/sasl/plain_authenticator.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class Net::IMAP::SASL::PlainAuthenticator
3737
attr_reader :authzid
3838

3939
# :call-seq:
40-
# new(username, password, authzid: nil) -> authenticator
40+
# new(username, password, authzid: nil, **) -> authenticator
41+
# new(username:, password:, authzid: nil, **) -> authenticator
4142
#
4243
# Creates an Authenticator for the "+PLAIN+" SASL mechanism.
4344
#
@@ -50,10 +51,13 @@ class Net::IMAP::SASL::PlainAuthenticator
5051
# * #authzid ― Alternate identity to act as or on behalf of. Optional.
5152
#
5253
# See attribute documentation for more details.
53-
def initialize(username, password, authzid: nil)
54-
raise ArgumentError, "username contains NULL" if username&.include?(NULL)
55-
raise ArgumentError, "password contains NULL" if password&.include?(NULL)
56-
raise ArgumentError, "authzid contains NULL" if authzid&.include?(NULL)
54+
def initialize(user = nil, pass = nil,
55+
username: nil, password: nil, authzid: nil, **)
56+
username ||= user or raise ArgumentError, "missing username"
57+
password ||= pass or raise ArgumentError, "missing password"
58+
raise ArgumentError, "username contains NULL" if username.include?(NULL)
59+
raise ArgumentError, "password contains NULL" if password.include?(NULL)
60+
raise ArgumentError, "authzid contains NULL" if authzid&.include?(NULL)
5761
@username = username
5862
@password = password
5963
@authzid = authzid

0 commit comments

Comments
 (0)