implementing user has password in hook menu

与世无争的帅哥 提交于 2019-12-25 03:41:19

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!