The current user_validate_current_pass function uses the global $user instead of the user object in $form. This makes it harder to reuse the function than it should be.

Comments

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new5.9 KB

The patch attached includes a dummy test module that has a custom form that uses user_validate_current_pass(). A test has been added to user.test that uses this form.

moshe weitzman’s picture

Status: Needs review » Needs work

The code fix looks good. Seems like lot of test code which I have not reviewed. I did notice a copy/paste snafu - "Tests that node access permissions are followed."

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new5.92 KB

Copy/paste snafu fixed.

The test code is so large as the point is to be able to reuse the user_validate_current_pass() function. In order to prove that code changes work (and the current code doesn't) a dummy test module is needed to provide a custom form using the validate function.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

OK, bug fixed.

damien tournoud’s picture

Just as a sanity check for everyone: the password confirmation widget only appears if the user being modified is also the current user, so $GLOBALS['user'] is the same as $form['#user'] when user_validate_current_pass is called.

alexpott’s picture

Yep Damien you are correct... I think this fix is more about code consistency than bug fixing.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

rfay’s picture

Title: user_validate_current_pass uses global $user and not the user object from the form » [HEAD BROKEN] user_validate_current_pass uses global $user and not the user object from the form
Status: Fixed » Needs work

This seems to have broken HEAD: http://qa.drupal.org/head-status

The commit was http://drupal.org/cvs?commit=462778

It looks to me like the problem is that the two files in the user_form_test module (modules/user/tests/user_form_test.info and modules/user/tests/user_form_test.module) didn't get committed.

webchick’s picture

Title: [HEAD BROKEN] user_validate_current_pass uses global $user and not the user object from the form » user_validate_current_pass uses global $user and not the user object from the form
Status: Needs work » Fixed

Added those two missing files. Hope that makes testbot happier.

rfay’s picture

webchick's replacement commit: http://drupal.org/cvs?commit=462852

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.