问题
we are implementing a web service for a Drupal 7 site (the web service code is not part of drupal installation folder).
one of the web services needs to sign up the user on the site. the main hurdle was getting a hashed password that Drupal will also recognize.
for that , am following a suggestion made on stack overflow to Implement a REST service inside drupal and call that from the outside service code . (that part also seems possible and achieveable).
have implemented a password hashing service with following code:
function GetHashedPassword($string)
{
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
$hashedpw = user_hash_password($string);
$data = array(
'password' => $hashedpw
);
header("Access-Control-Allow-Origin: *");
drupal_json_output($data);
drupal_exit();
}
the main issue now is that whenever this service is called even with same string , it returns a new hashed value each time..
kindly assist if what we need is actually even possible and if so, then what could be fixed in the above code
any help appreciated
回答1:
The Drupal user_hash_password function generates a new salt each time it calculates the hash. This will cause a new hash to be generated since the salt is likely to be different to the last one.
来源:https://stackoverflow.com/questions/29489308/implementing-user-has-password-in-hook-menu