douhe6181 2016-10-11 16:22
浏览 57

在cakePHP 3中使用openID Steamauthentification

I try to get OpenID Steamauthentification working in my cakePHP3 app using this as my source: https://github.com/SmItH197/SteamAuthentication

I made a new Authenticate Component and it works fine but i had to add some lines of code (marked with //+) which just dont make sense in my view:

    public function authenticate(Request $request, Response $response)
    {

        $openid = new \LightOpenID($steamauth['domainname']);

        debug($openid);//+
        if (!$openid->mode) {
            $openid->identity = 'http://steamcommunity.com/openid';
            header('Location: ' . $openid->authUrl());
            $openid->authUrl();//+
            debug($openid);//+
        } elseif ($openid->mode == 'cancel') {
            echo 'User has canceled authentication!';
        } else {
            if ($openid->validate()) {
                $id = $openid->identity;
                $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
                preg_match($ptn, $id, $matches);

                debug($matches[1]);// steam id
                return $matches;
            } else {
                return false;
            }
        }
        return false;
    }

So without those 3 lines it doesnt work. debug is returning the variable itself and authUrl() is returning an Url String. Does anyone have an idea why i have to return the variables to get this running? Could this be a PHP7 issue?

The appropriate method can be found in the githubrep file steamauth.php.

  • 写回答

1条回答 默认 最新

  • dop83362 2016-10-14 07:41
    关注

    authUrl() : is the Authenticate url request for according to your Auth Version Check here Line 854

    function return : Function Return mostly TRUE and FALSE if any data return then it works as true; if not then it returns as false.

    In your case, if you return TRUE

    return true;
    

    instate of

     return $matches;
    

    it also should also work

    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办