【问题标题】:Using openID Steamauthentification in cakePHP 3在 cakePHP 3 中使用 openID Steamauthentification
【发布时间】:2016-10-11 16:22:19
【问题描述】:

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

我制作了一个新的 Authenticate 组件,它工作正常,但我不得不添加一些代码行(标有 //+),这在我看来是没有意义的:

    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中找到。

【问题讨论】:

    标签: php cakephp openid cakephp-3.0


    【解决方案1】:

    authUrl() :是根据您的身份验证版本Check here Line 854的身份验证网址请求@

    function return : Function Return 主要是 TRUEFALSE 如果有任何数据返回则它作为 true;如果不是,则返回 false。

    在你的情况下,如果你返回 TRUE

    return true;
    

    状态

     return $matches;
    

    它也应该可以工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-20
      • 2020-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-07
      相关资源
      最近更新 更多