summaryrefslogtreecommitdiff
path: root/lib/rbot/botuser.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-02-15 00:11:17 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-02-15 00:11:17 +0000
commit7d665ab68a88b01431c7b51153507c9a98fd6333 (patch)
treef66c3c1244e9aca9c18675fa571351959b73b72d /lib/rbot/botuser.rb
parent5ef7f7f853215ee2bf64a7b665c6f696b7bdf4b1 (diff)
Stringify password when creating botuser. Useful when e.g. conf.yaml contains a master password which is numeric and unquoted
Diffstat (limited to 'lib/rbot/botuser.rb')
-rw-r--r--lib/rbot/botuser.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/rbot/botuser.rb b/lib/rbot/botuser.rb
index 52b83151..c0041d7f 100644
--- a/lib/rbot/botuser.rb
+++ b/lib/rbot/botuser.rb
@@ -263,18 +263,19 @@ module Irc
# This method sets the password if the proposed new password
# is valid
def password=(pwd=nil)
- if pwd
+ pass = pwd.to_s
+ if pass.empty?
+ reset_password
+ else
begin
- raise InvalidPassword, "#{pwd} contains invalid characters" if pwd !~ /^[A-Za-z0-9]+$/
- raise InvalidPassword, "#{pwd} too short" if pwd.length < 4
- @password = pwd
+ raise InvalidPassword, "#{pass} contains invalid characters" if pass !~ /^[A-Za-z0-9]+$/
+ raise InvalidPassword, "#{pass} too short" if pass.length < 4
+ @password = pass
rescue InvalidPassword => e
raise e
rescue => e
- raise InvalidPassword, "Exception #{e.inspect} while checking #{pwd}"
+ raise InvalidPassword, "Exception #{e.inspect} while checking #{pass.inspect} (#{pwd.inspect})"
end
- else
- reset_password
end
end