Um zu vermeiden, dass ein Benutzer sich doppelt für Roundcube anmelden muss, wenn man unterschiedliche Formulare, Portale, Interfaces… benutzt, kann das Plugin Autologon verwendet werden.
Plugin aktivieren:
/roundcube/config/main.inc.php
$rcmail_config['plugins'] = array('autologon');
Autologon konfigurieren:
/roundcube/plugins/autologon/autologon.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<?php /** * Sample plugin to try out some hooks. * This performs an automatic login if accessed from localhost */ class 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(); // change action to login 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; } } |
HTML Formular:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<form name="form" action="roundcube/index.php" method="post"> <input type="hidden" name="_action" value="login" /> <input type="hidden" name="_task" value="login" /> <input type="hidden" name="_autologin" value="1" /> <table border="0"> <tr> <td>Benutzername:</td> <td> <input name="_user" id="rcmloginuser" size="28" type="text" /></td> </tr> <tr> <td>Passwort:</td> <td> <input name="_pass" id="rcmloginpwd" size="28" type="password"/></td> </tr> <tr> <td> <input class="Button" type="submit" size="28" value="Webmail Login"/></td> </tr> </table> </form> |