I am currently working on a customized user registration page. It worked fine to a point I was able to save users into the database. The user will enter their default password on the form, so I hashed it and stored in the pass column in the users table.
$hashedpassword = user_hash_password(check_plain($form_state['values']['password']));
But after a test user entered, i was not able to login to the site. I am getting this password mismatch error. Here is what I found out so far:
//return a valid user account if the user data successfully saved into database
$newaccount = user_save(null, $newUser);
drupal_set_message('plain password before user_hash_password() is : '.$form_state['values']['password']);
drupal_set_message('Password in $account after user saved :'.$newaccount->pass);
if (user_check_password($form_state['values']['password'], $newaccount))
{
drupal_set_message(t('passwords match'));
}
else
{
drupal_set_message(t('passwords not match'));
}
Here are the output:
plain password before user_hash_password() is : er23er
Password in $account after user saved :$S$Cy5ZuH9713b.t71/TtEmJDLlW1GvyZwwqUzDiG2yzdo1iEjkIbPK
stored hash variable in user_check_password is : $S$Cy5ZuH9713b.t71/TtEmJDLlW1GvyZwwqUzDiG2yzdo1iEjkIbPK
plain password before _password_crypt call is : er23er