duanbimo7212 2013-11-20 10:17
浏览 32
已采纳

Magento SOAP客户身份验证?

I'm currently looking at creating a mobile application which integrates with a Magento store and have managed to get many aspects of it working using the SOAP API such as retrieving products and categories.

I am now looking to solve an issue where I need the user of the mobile app to login in with their Magento customer login details, however looking through the SOAP API there is no method for an actual customer to login?

Does anyone have any idea of how I can perform this task.

Thanks

  • 写回答

2条回答 默认 最新

  • dsagzmosl32217092 2014-03-07 11:06
    关注

    Actually its quite easy to authenticate a customer in your case. The customer info SOAP response gives us the password_hash of the user registered in Magento. This hash is an md5 hash which can authenticated using the password which the user will enter along with his email in your system. I have a sample code below hope this helps anyone looking for this answer.

    $complexFilter = array(
        'complex_filter' => array(
            array(
                'key' => 'email',
                'value' => array('key' => 'eq', 'value' => 'someemail@gmail.com')
            )
        )
    );
    $result = $proxy->customerCustomerList($sessionId, $complexFilter);
    
    var_dump($result);
    
    /**
     * Validate hash against hashing method (with or without salt)
     *
     * @param string $password
     * @param string $hash
     * @return bool
     */
    function validateHash($password, $hash)
    {
        $hashArr = explode(':', $hash);
    
        switch (count($hashArr)) {
            case 1:
                return md5($password) === $hash;
            case 2:
                return md5($hashArr[1] . $password) === $hashArr[0];
        }
    }
    
    var_dump(validateHash('asdfgh',$result[0]->password_hash));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示