0
0
Ruby on Railsframework~5 mins

has_secure_password in Ruby on Rails - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does has_secure_password do in a Rails model?
It adds methods to set and authenticate a password securely using bcrypt. It also adds validations for password presence and confirmation.
Click to reveal answer
beginner
Which gem must be included in your Rails project to use has_secure_password?
The bcrypt gem is required because it handles password hashing securely.
Click to reveal answer
beginner
What database column is required to use has_secure_password?
A string column named password_digest must exist in the model's table to store the hashed password.
Click to reveal answer
intermediate
How do you check if a password is correct using has_secure_password?
Use the authenticate method on the model instance, passing the password. It returns the user if correct, or false if not.
Click to reveal answer
intermediate
What validations does has_secure_password add automatically?
It validates that the password is present on creation and that password confirmation matches if provided.
Click to reveal answer
Which column must be added to your database table to use has_secure_password?
Apassword_digest
Bpassword
Cencrypted_password
Dpassword_hash
What gem is required to use has_secure_password in Rails?
Aopenssl
Bdevise
Crails-password
Dbcrypt
What method does has_secure_password add to check a password?
Averify_password
Bcheck_password
Cauthenticate
Dvalidate_password
Which validation is automatically added by has_secure_password?
APassword length minimum 12
BPassword presence on creation
CUsername uniqueness
DEmail format validation
What happens if you call authenticate with a wrong password?
AReturns false
BRaises an error
CReturns the user object
DReturns nil
Explain how has_secure_password helps secure user passwords in Rails.
Think about how passwords are stored and checked safely.
You got /4 concepts.
    Describe the steps to add password authentication to a Rails model using has_secure_password.
    Consider what you need in the database, code, and how to check passwords.
    You got /4 concepts.