Roundcube Community Forum

Third Party Contributions => API Based Plugins => Topic started by: Pantani on December 06, 2013, 09:25:37 AM

Title: My autologin plugin does not work well
Post by: Pantani on December 06, 2013, 09:25:37 AM
I want to autenticate my own users to their webmail account. It works with form and plugin below - it's a clone of in Roundcube included autologon plugin. But when I close the browser's window or tab and send immediately this form again, the window with roundcubemail is opened, the user seems to be authenticated,  but none messages are shown and error message occurs: 'Invalid request! No data was saved.'.
Why? What I'm doing bad? Do you see something wrong in the plugin or in the form?

Best regards
Tomas


<form id="webmail-form" action="https://ouweb/index.php" method="post" target="webmail">
  <input type="hidden" value="1" name="_autologin">
  <input type="hidden" value="" name="user">
  <input type="hidden" value="" name="pass">
</form>

class our_autologon extends rcube_plugin {
    public $task = 'login';

    function init() {
        $this->add_hook('startup', array($this, 'startup'));
        $this->add_hook('authenticate', array($this, 'authenticate'));
    }

    function startup($args) {
        $rcmail = rcmail::get_instance();

        if (empty($_SESSION['user_id']) && !empty($_POST['_autologin']))
            $args['action'] = 'login';

        return $args;
    }

    function authenticate($args) {
        if (!empty($_POST['_autologin'])) {
            $args['user'] = $_POST['user'];
            $args['pass'] = $_POST['pass'];
            $args['cookiecheck'] = false;
            $args['valid'] = true;
        }

        return $args;
    }
}
Title: Re: My autologin plugin does not work well
Post by: SKaero on December 06, 2013, 02:47:13 PM
Try changing the form url to: https://ouweb/index.php?_task=login
Title: Re: My autologin plugin does not work well
Post by: Pantani on December 09, 2013, 02:11:40 AM
Thank you, I just tried to change the URL to https://ouweb/index.php?_task=login (hope your "&" char is a typo) or add the new form element <input type="hidden" value="login" name="_task">. Both leads to "Invalid request! No data was saved.". The user cannot login at all with this new parameter.
Any other hints?