实现用户在钩子菜单中有密码 [英] implementing user has password in hook menu

查看:575
本文介绍了实现用户在钩子菜单中有密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为Drupal 7网站实施Web服务(Web服务代码不是drupal安装文件夹的一部分)。



其中一个Web服务需要在网站上注册用户。
主要障碍是得到Drupal也会识别的哈希密码。



为此,我按照堆栈溢出的建议,在drupal内部实施REST服务,并从外部服务代码中调用。 (这一部分看起来也可能实现)。



已使用以下代码实施密码散列服务:

 函数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();
}

现在的主要问题是,即使使用相同的字符串调用此服务,它每次返回一个新的哈希值。



如果我们需要的是甚至可能,请帮助,如果是这样,那么上面的代码可以修复什么

任何帮助赞赏

解决方案

Drupal user_hash_password 函数在每次计算哈希时生成一个新的盐。这将导致产生一个新的散列,因为盐可能与最后一个不同。


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

解决方案

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.

这篇关于实现用户在钩子菜单中有密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆