1

编辑:现在它正在工作,是 LimeSurvey 中的一个错误。

我为 LimeSurvey 2.05beta5 创建了简单的登录插件,只是为了测试它是否正常工作。

问题是,该事件 newUserSession 永远不会被调用。文档也很糟糕,因为仍处于测试阶段......

这是插件代码:

<?php
    class TestLogin extends AuthPluginBase
    {
        protected $storage = 'DbStorage';    

        static protected $description = 'Testing login system...';
        static protected $name = 'TestLogin';

        public function __construct(PluginManager $manager, $id) {
            parent::__construct($manager, $id);

            $this->subscribe('beforeLogin');
            $this->subscribe('newUserSession');
        }

        public function beforeLogin()
        {      
        if (isset($_GET["testlogin"]) && ($_GET["testlogin"] == 1)) {  
            $this->setUsername('admin');
            $this->setAuthPlugin();
        }
        }

        public function newUserSession()
        {
            $sUser = $this->getUserName();        
            $oUser = $this->api->getUserByName($sUser);

            if (!is_null($oUser))
            {
                $this->setAuthSuccess($oUser);
                return;
            } else {
                $this->setAuthFailure(self::ERROR_USERNAME_INVALID);
            }       
        }   
    }
?>

要调用此代码,只需转到以下网址:admin/authentication/sa/login?testlogin=1

我错过了什么?

4

1 回答 1

2

工作中

这是工作解决方案:https ://github.com/LimeSurvey/LimeSurvey/commit/9df25ebcdb44d32295f64e5996d13fddf12e4bb6

于 2013-08-10T12:47:40.487 回答