2

我正在尝试在 Yii 用户管理插件上设置混合身份验证,文档在这里https://github.com/thyseus/yii-user-management/blob/master/user/docs/hybridauth.txt

按照这个步骤

Take the modules/user/vendors/index.php, rename it to 'hybridauth.php' and place it 
    beside your application index.php bootstrap script. This will be your hybrid auth
    entry script. 

为此,没有 index.php 文件,modules/user/vendors/index.php但有一个modules/user/vendors/hybridauth/index.php我重命名为hybridauth.php并将其放入http://localhost/dev/hybridauth.php 的内容中

require_once( "protected/modules/user/vendors/hybridauth/Hybrid/Auth.php" );

require_once( "protected/modules/user/vendors/hybridauth/Hybrid/Endpoint.php" ); 

Hybrid_Endpoint::process();

现在为此

Place the hybrid auth configuration file into your application
protected/config/hybridauth.php. 

modules/user/vendors/hybridauth/config.php把它放进去,protected/config/并将config.php重命名为hybridauth.php。内容看起来像这样

return 
    array(
        "base_url" => Yii::app()->createAbsoluteUrl('/').'/hybridauth.php',
        "providers" => array ( 
            
...........
            "Google" => array ( 
                "enabled" => true,
                "keys"    => array (  
                            "id" => "ID", 
                            "secret" => "SECRET",
                        ), 
            ),

            "Facebook" => array ( 
                "enabled" => true,
                "keys"    => array ( 
                        "id" => "ID", 
                        "secret" => "SECRET",
                ), 
                "scope" => "email,user_birthday" // https://developers.facebook.com/docs/reference/login/
            ),
        ),

        // if you want to enable logging, set 'debug_mode' to true  then provide a writable file by the web server on "debug_file"
        "debug_mode" => false,

        "debug_file" => "",
    );

问题是当我点击登录页面上的 Facebook 图标时,它会显示我的主页。(索引.php)

这里也是它指向的链接

http://localhost/dev/index.php/hybridauth.php?hauth.start=Facebook&hauth.time=1388044835

当我从 url 中删除 index.php

http://localhost/dev/hybridauth.php?hauth.start=Facebook&hauth.time=1388044835

我得到这个错误

您无法直接访问此页面。

知道我做错了什么吗?谢谢

4

3 回答 3

0

if anyone having the same problem, here is how i solved it:

by changing the base_url to point to the actual php file:

"base_url" => Yii::app()->getBaseUrl(true).'/hybridauth.php', 
于 2014-06-12T07:05:47.450 回答
0

如果您使用 YUM 用户管理尝试导入

 Yii::import('application.modules.profile.models.*');

在 YumUserAuthController 上,因为找不到配置文件。

于 2015-01-16T16:59:38.080 回答
0

这听起来像是您的配置中的路由问题:

您可能想为 hybridauth.php 添加路由并确保它只能通过 GET 访问

例如 :

'components'=>array(
    ......
    'urlManager'=>array(
        'showScriptName' => false,
        'urlFormat'=>'path',
        'rules'=>array(
            'hybridauth'=>array('user/hybridauth/index', 'verb'=>'GET', 'urlSuffix'=>'.php'),
             ....
        ),
    ),
),
于 2014-01-03T16:44:54.370 回答