aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorMikel Lindsaar <mikel@rubyx.com>2010-12-19 21:28:37 +1100
committerMikel Lindsaar <mikel@rubyx.com>2010-12-19 21:36:47 +1100
commit6c217f98db6984c8d000103ac3cf66970eeaeb3f (patch)
tree2fa8b1d24957d03c112fe441325718a530723470 /activemodel/lib
parentfa14df08a845abc61a6ed5bed1742ba59a4c2b8d (diff)
downloadrails-6c217f98db6984c8d000103ac3cf66970eeaeb3f.tar.gz
rails-6c217f98db6984c8d000103ac3cf66970eeaeb3f.tar.bz2
rails-6c217f98db6984c8d000103ac3cf66970eeaeb3f.zip
Add set_weak_passwords call in alignment with set_table_name.
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/secure_password.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb
index c5f32fa3fa..6703d5daac 100644
--- a/activemodel/lib/active_model/secure_password.rb
+++ b/activemodel/lib/active_model/secure_password.rb
@@ -41,12 +41,18 @@ module ActiveModel
validate :password_must_be_strong
end
- # Allows you to specify the set of weak passwords that will be validated against
- # if you specify has_secure_password in your model:
+ # Specify the weak passwords to be used in the model:
#
- # class User < ActiveRecord::Base
- # weak_passwords = %w( password qwerty 123456 mypass )
+ # class User
+ # weak_passwords %w( password qwerty 123456 mypass )
# end
+ def set_weak_passwords(values)
+ @weak_passwords = values
+ end
+
+ # Change the list of weak passwords that will be validated against:
+ #
+ # User.weak_passwords = %w( password qwerty 123456 mypass )
def weak_passwords=(*values)
@weak_passwords = values.flatten
end
@@ -55,7 +61,7 @@ module ActiveModel
# list of 'password', 'qwerty' and '123456'
#
# User.weak_passwords #=> ['password', 'qwerty', '123456']
- def weak_passwords
+ def weak_passwords(values = nil)
@weak_passwords ||= %w( password qwerty 123456 )
end