在cakePHP 3中使用openID蒸汽认证



我尝试在我的cakePHP3应用程序中使用此作为我的源:https://github.com/SmItH197/SteamAuthentication

我做了一个新的认证组件,它工作得很好,但我不得不添加一些代码行(用//+标记),这在我看来没有意义:

    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;
    }

所以没有这3行,它不能工作。debug返回变量本身,authUrl()返回Url字符串。有人知道为什么我要返回变量来运行这个吗?这是PHP7的问题吗?

适当的方法可以在githubrep文件steamauth.php中找到。

authUrl():是认证url请求根据您的认证版本检查这里第854行

函数返回:函数返回大部分TRUEFALSE如果有任何数据返回,则它作为TRUE工作;如果不是,则返回false。

在你的例子中,如果你返回TRUE

return true;

状态

 return $matches;

也可以

最新更新