html form - rails, provide visual feedback on a password, yet keeping it secure -
I have a password stored in the database
The user should be able to set a new one.
I have also used to store an entry-encrypted gem as an encrypted text (symmetric because I need to connect it to other services and not just to enter), but it's another The story is there.
When I show the form, The default behavior of Ruby Headers is not sending back passwords in the browser for obvious security reasons.
Here's the code:
< Code> & lt;% = f.input: app_password ,: as = & gt; : Password% & gt;
This behavior can be fine, yet some issues arise.
- If the user saves the form with an empty password, the password will be deleted. I should check the password-saving password, but in some applications the password is acceptable and I can stop this possibility from doing so.
- This does not provide user feedback on the fact that he or she has compiled the password field
- It does not play very well with assumptions
Here are my options for getting the most possible possible behavior (i.e., a 'change password'), such as password fields are included in this way:
< / Div>
code> & lt;% = f.password_field: app_password% & gt;
Standard Usage and password set is:
Add to your user model
has_secure_password
Add fields to users to store an encrypted password : Migration:
add_column: users ,: auth_token ,: string
Before generating a token:
get started self.auth_token = SecureRandom .urlsafe_base64 End User while Axis? (Auth_token: self.auth_token)
Authenticate with your user
@. Authentication (params [: password])
Update the password on any other form with 3 fields, old_password, password and password_confirmation.
Comments
Post a Comment