2017-02-15 37 views
0

目前正在使用Shoutbox并使用LightOpenID提供Steam登录方法。我也在使用Yii2框架。任何帮助将不胜感激!提前致谢。lightopenid不会发布会话变量

下面是index.php,它根据SteamID发布数据。

<?php 

/* @var $this yii\web\View */ 
/* @var $form yii\bootstrap\ActiveForm */ 
/* @var $model app\models\LoginForm */ 

use yii\helpers\Html; 
use yii\bootstrap\ActiveForm; 

$this->title = 'Dashboard'; 
$this->params['breadcrumbs'][] = $this->title; 

require "steamauth/steamauth.php"; 

if(!isset($_SESSION['steamid'])) { 

    echo('Hitting no steamid marker'); 

    $localUserName = "Guest"; 

    } else { 

    include ('steamauth/userInfo.php'); 

    $localUserName = ucfirst($_SESSION['steam_personaname']); 
    }; 

if (!isset($_SESSION['steamid'])) { 
    echo ("<div class='well'> 
    <div class='jumbotron'> 
    <h1>Login here.</h1> 
    <p>This prevents x from having to store user passwords. Powered by <a href='http://www.steampowered.com'><strong>STEAM</strong></a>.</p> 
    <p><a id='steamlogin' href='?r=user-record/index&login=1' class='btn btn-success btn-large loginButton'><span class='glyphicon glyphicon-log-in'></span> Login through Steam</a></p> 
    </div> 
    </div>"); 
    $this->title = 'Login'; 

} else { 

    echo(" 
     <div class='well'> 
     <div class='jumbotron'> 
     <h1>Dashboard</h1> 
     <p>Hey there, <a href=". $_SESSION['steam_profileurl'] . "><strong>" . $_SESSION['steam_personaname'] . "</strong></a>. </p> 
     <p><img src=" . $_SESSION['steam_avatarfull'] . "</img></p> 
     <p>Steam ID: <strong>" . $_SESSION['steamid'] . "</strong></p> 


     <p> 
     <p><a id='steamlogout' href='?r=user-record/index&logout=1' class='btn btn-danger btn-large logoutButton'><span class='glyphicon glyphicon-log-out'></span> Disconnect</a></p> 
     </div> 
     </div>"); 
} 
?> 

这是授权文件,这使它一路返回authURL但然后继续回到登录页面重定向不设置任何变量。期待它返回“蒸汽”。

ob_start(); 
if (isset($_GET['login'])){ 
    require 'openid.php'; 
    echo('login initiated'); 
    try { 
     echo('try initiiated'); 
     require 'SteamConfig.php'; 
     $openid = new LightOpenID($steamauth['domainname']); 

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

       $_SESSION['steamid'] = $matches[1]; 
       if (!headers_sent()) { 
        header('Location: '.$steamauth['loginpage']); 
        exit; 
       } else { 
        ?> 
        <script type="text/javascript"> 
         window.location.href="<?=$steamauth['loginpage']?>"; 
        </script> 
        <noscript> 
         <meta http-equiv="refresh" content="0;url=<?=$steamauth['loginpage']?>" /> 
        </noscript> 
        <?php 
        exit; 
       } 
      } else { 
       echo "User is not logged in.\n"; 
      } 
     } 
    } catch(ErrorException $e) { 
     echo $e->getMessage(); 
    } 
} 
+0

什么时候开始使用他们的所有文件里面的会议? –

+0

就这么简单。哇。谢谢。 –

+0

不客气。如果您希望将其标记为已解决,我会在那里为您弹出一个答案 –

回答