`has_secure_password` is not invalid when assigning empty Strings #9545

Merged
merged 2 commits into from Mar 7, 2013

Projects

None yet

4 participants

@senny
Member
senny commented Mar 4, 2013

Closes #9535.

With 692b3b6 the password= setter does no longer set blank passwords.
This triggered validation errors when assigning empty Strings to password
and password_confirmation.

This patch only sets the confirmation if it is not blank?.

senny added some commits Mar 4, 2013
@senny senny `validates_confirmation_of` does not override writer methods. b501ee4
@senny senny `has_secure_password` is not invalid when assigning empty Strings.
Closes #9535.

With 692b3b6 the `password=` setter does no longer set blank passwords.
This triggered validation errors when assigning empty Strings to `password`
and `password_confirmation`.

This patch only sets the confirmation if it is not `blank?`.
8c1687b
@senny
Member
senny commented Mar 4, 2013

/cc @josevalim (I saw that you merged 692b3b6)

@rafaelfranca @carlosantoniodasilva could you take a look?

@senny
Member
senny commented Mar 4, 2013

The change to validates_confirmation first commit is a bit controversial. One could argue that when you have a writer, you are also responsible for the getter and therefore it wouldn't override. Let me know If you like that approach better and I revert the change (I think we should keep the tests to document the behaviour though).

@rafaelfranca rafaelfranca merged commit cf09ac3 into rails:master Mar 7, 2013
@josevalim

Isn't this the wrong indentation?

Member

it is but looks like it was fixed on 4-0-stable and it's not on master anymore:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment