Question

Edit: Now it's working, was an bug in LimeSurvey.

I created simple login plugin for LimeSurvey 2.05beta5 just to test, if it is working.

Problem is, that event newUserSession is never called. Documentation is also really bad, because is still in beta...

Here is the plugin code:

<?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);
            }       
        }   
    }
?>

To call this code, just go to this url: admin/authentication/sa/login?testlogin=1

I'm missing something?

Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top