implementing user has password in hook menu

2019-09-05 15:04发布

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

标签: php drupal-7
1条回答
叼着烟拽天下
2楼-- · 2019-09-05 15:20

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.

查看更多
登录 后发表回答