diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-07-08 13:56:07 +0300 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-07-08 14:12:27 +0300 |
commit | e62e68e25bb7b1281e20e228db66f7deace4330f (patch) | |
tree | 68eca51697a69c7aca81553c99deeab87cffd79d /guides | |
parent | e8682c5bf051517b0b265e446aa1a7eccfd47bf7 (diff) | |
download | rails-e62e68e25bb7b1281e20e228db66f7deace4330f.tar.gz rails-e62e68e25bb7b1281e20e228db66f7deace4330f.tar.bz2 rails-e62e68e25bb7b1281e20e228db66f7deace4330f.zip |
has_secure_password: use `recovery_password` instead of `activation_token`
Since we have `has_secure_token`, it is too confusing to use `_token`
suffix with `has_secure_password`.
Context https://github.com/rails/rails/pull/33307#discussion_r200807185
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/active_model_basics.md | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/guides/source/active_model_basics.md b/guides/source/active_model_basics.md index bad3543924..09b4782eca 100644 --- a/guides/source/active_model_basics.md +++ b/guides/source/active_model_basics.md @@ -466,7 +466,7 @@ a `password` accessor with certain validations on it by default. `ActiveModel::SecurePassword` depends on [`bcrypt`](https://github.com/codahale/bcrypt-ruby 'BCrypt'), so include this gem in your `Gemfile` to use `ActiveModel::SecurePassword` correctly. In order to make this work, the model must have an accessor named `XXX_digest`. -Where `XXX` is the attribute name of your desired password/token or defaults to `password`. +Where `XXX` is the attribute name of your desired password. The following validations are added automatically: 1. Password should be present. @@ -479,9 +479,9 @@ The following validations are added automatically: class Person include ActiveModel::SecurePassword has_secure_password - has_secure_password :activation_token, validations: false + has_secure_password :recovery_password, validations: false - attr_accessor :password_digest, :activation_token_digest + attr_accessor :password_digest, :recovery_password_digest end person = Person.new @@ -506,16 +506,16 @@ person.valid? # => true person.password = person.password_confirmation = 'aditya' person.valid? # => true -person.activation_token = "a_new_token" +person.recovery_password = "42password" person.authenticate('aditya') # => person person.authenticate('notright') # => false person.authenticate_password('aditya') # => person person.authenticate_password('notright') # => false -person.authenticate_activation_token('a_new_token') # => person -person.authenticate_activation_token('notright') # => false +person.authenticate_recovery_password('42password') # => person +person.authenticate_recovery_password('notright') # => false -person.password_digest # => "$2a$04$l4yYxoUPibMXcvvu.Lq8M.T/rtjdLOA78LN2XHEzMovf7hWVGzgXC" -person.activation_token_digest # => "$2a$10$0Budk0Fi/k2CDm2PEwa3BeXO5tPOA85b6xazE9rp8nF2MIJlsUik." +person.password_digest # => "$2a$04$gF8RfZdoXHvyTjHhiU4ZsO.kQqV9oonYZu31PRE4hLQn3xM2qkpIy" +person.recovery_password_digest # => "$2a$04$iOfhwahFymCs5weB3BNH/uXkTG65HR.qpW.bNhEjFP3ftli3o5DQC" ``` |