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 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题