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?

Comments

kscheirer’s picture

kscheirer’s picture

Status: Active » Needs review
StatusFileSize
new692 bytes

here's the simplest patch, just using strcmp() instead. switching form elements probably requires more testing :)

rszrama’s picture

Status: Needs review » Fixed

Thanks 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. :-/

rszrama’s picture

Title: bug in password confirm code » Update password collection in checkout to use FAPI's password_confirm
Version: 6.x-2.0-rc3 » 6.x-2.x-dev
Category: bug » feature
Priority: Critical » Normal
Status: Fixed » Postponed

And 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!

kscheirer’s picture

I 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.

rszrama’s picture

Yeah, it was committed when I moved this to fixed in #3.

tr’s picture

Status: Postponed » Active

This should have been set back to active as soon as 2.0 was released. Reopening.

longwave’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Category: feature » task

Bumping to 7.x. Not strictly a feature request either!

longwave’s picture

Status: Active » Needs review
StatusFileSize
new1.61 KB

The 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.

Status: Needs review » Needs work

The last submitted patch, 497958-checkout-password_confirm.patch, failed testing.

longwave’s picture

Status: Needs work » Closed (won't fix)

I 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.