Check out the LimeSurvey source code on GitHub!

Login plugin - 2.05beta5

More
3 years 5 months ago #98595 by atlet
I created simple login plugin just to test, if it is working.

Problem is, that event newUserSession is never called.

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?

Please Log in to join the conversation.

More
3 years 5 months ago #98598 by mdekker
Ah I now see the problem, I committed a fix to the 2.05 branch on github:

github.com/LimeSurvey/LimeSurvey/commit/...4e5996d13fddf12e4bb6

---
Menno Dekker
The following user(s) said Thank You: atlet

Please Log in to join the conversation.

More
3 years 5 months ago #98602 by atlet
Tnx, now it's working fine.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form