I was poking through the code that validates the new user info in uc_cart_checkout_pane.inc::uc_checkout_pane_customer(), and I noticed you've got if ($arg2['new_account']['pass'] != $arg2['new_account']['pass_confirm']) { //error }. This works great except it does type conversion and will allow a few false matches through. Try 999 and 999.0, they are not the same obviously but will pass validation.
Drupal core had this bug as well until very recently: [[398902]].
Possible solutions: use strcmp() instead of !=, this will validate properly. Or leverage password_confirm_validate() somehow instead?
Actually, now that I'm looking at the form, why isn't it using the password_confirm FAPI element? This gets automatically expanded into a password and confirmation field, and handles validation. Set $contents['new_account']['pass']['#type'] = 'password_confirm' and then you don't need $contents['new_account']['pass_confirm'] at all?
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 497958-checkout-password_confirm.patch | 1.61 KB | longwave |
| #2 | 497958_uc_password_confirm.patch | 692 bytes | kscheirer |
Comments
Comment #1
kscheirersorry link should be #398902: passwords are not type-checked
Comment #2
kscheirerhere's the simplest patch, just using strcmp() instead. switching form elements probably requires more testing :)
Comment #3
rszrama commentedThanks for catching this! It isn't using that element b/c we never had a chance to do a full D6 update to take advantage of new features like that. We've been pushing for a 2.0 release for some time, but it eludes us. :-/
Comment #4
rszrama commentedAnd just for ease of remembrance... this issue can be the feature request down the road. : )
tbh, I didn't even know this form element existed!
Comment #5
kscheirerI think you should use the patch in the mean time, it does close the bug, and then you can refactor later down the road to use password_confirm.
Comment #6
rszrama commentedYeah, it was committed when I moved this to fixed in #3.
Comment #7
tr commentedThis should have been set back to active as soon as 2.0 was released. Reopening.
Comment #8
longwaveBumping to 7.x. Not strictly a feature request either!
Comment #9
longwaveThe attached patch implements this, but I'm not sure we should use it. It adds the password strength meter and tips, which some users might not want.
Comment #11
longwaveI tested this again and it just looks too ugly to me, feel free to reopen if there are any other valid reasons for using this though.