-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Fix in has_secure_password for passwords containing only spaces. #16412
Conversation
@@ -76,6 +76,7 @@ def has_secure_password(options = {}) | |||
|
|||
validates_length_of :password, maximum: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED | |||
validates_confirmation_of :password, if: ->{ password.present? } | |||
validates_presence_of :password, unless: ->{ password.nil? } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To forbid passwords contains only spaces, and give relevant error message.
Not sure if we need actually want to block blank passwords. It seems like the original code was written this way to catch the |
I think it would be reasonable behavior, if we accept spaces as any other char. |
seems good to me! can you add a changelog along the lines of "Fixed (what wasn't working). (Offer suggestion for those who preferred the original behavior)."? 😄 |
Also, can you squash your commits? |
Fix in has_secure_password for passwords containing only spaces.
Not sure if this is the commit to blame as I migrated from |
Steps: