Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to custom field on has_secure_password #1694

Closed
wants to merge 1 commit into from
Closed

Add support to custom field on has_secure_password #1694

wants to merge 1 commit into from

Conversation

tinogomes
Copy link
Contributor

Schema: Account(name:string, phrase:string)

class Account < ActiveRecord::Base
has_secure_password :password, :phrase
end

account = Account.create
account.errors[:phrase] # => ["can't be blank"]

account = Account.new(:name => "david", :password => "", :password_confirmation => "nomatch")
account.save # => false, password required
account.password = "mUc3m00RsqyRe"
account.save # => false, confirmation doesn't match
account.password_confirmation = "mUc3m00RsqyRe"
account.save # => true
account.authenticate("notright") # => false
account.authenticate("mUc3m00RsqyRe") # => account
Account.find_by_name("david").try(:authenticate, "notright") # => nil
Account.find_by_name("david").try(:authenticate, "mUc3m00RsqyRe") # => account

@dmathieu
Copy link
Contributor

This feature has already been proposed and rejected by the core team. See #1440.

@tinogomes
Copy link
Contributor Author

Sorry guys for this pull request. I haven't saw the previous discussions about it.

@tinogomes tinogomes closed this Jun 14, 2011
svenfuchs pushed a commit to svenfuchs/rails that referenced this pull request Jul 2, 2011
… file rather than creating a new file "REVISION_ce706..." each time [rails#1694 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants