Roundcube Community Forum

 

My autologin plugin does not work well

Started by Pantani, December 06, 2013, 09:25:37 AM

Previous topic - Next topic

Pantani

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

SKaero

#1
Try changing the form url to: https://ouweb/index.php?_task=login

Pantani

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?