Roundcube/Plugin/autologon: Unterschied zwischen den Versionen
Die Seite wurde neu angelegt: „== autologon == <blockquote>Performs an auto login from an external page</blockquote> * Shipped by <code>Roundcube</code> * Plugin name: ''autologon'' You have to modify the default Thomas Bruederli's sample plugin like this (eventually change to $_GET): <?php →* * Sample plugin to try out some hooks. * This performs an automatic login if accessed from localhost * * @license GNU GPLv3+ * @author Thomas Bruederli: class autologon exte…“ |
K Textersetzung - „<blockquote>“ durch „“ |
||
Zeile 1: | Zeile 1: | ||
== autologon == | == autologon == | ||
Performs an auto login from an external page</blockquote> | |||
* Shipped by <code>Roundcube</code> | * Shipped by <code>Roundcube</code> |
Version vom 27. August 2023, 14:13 Uhr
autologon
Performs an auto login from an external page
- Shipped by
Roundcube
- Plugin name: autologon
You have to modify the default Thomas Bruederli's sample plugin like this (eventually change to $_GET):
<?php /** * Sample plugin to try out some hooks. * This performs an automatic login if accessed from localhost * * @license GNU GPLv3+ * @author Thomas Bruederli */ 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']) && $this->is_localhost()) $args['action'] = 'login'; return $args; } function authenticate($args) { if (!empty($_POST['_autologin']) && $this->is_localhost()) { $args['user'] = $_POST['_user']; $args['pass'] = $_POST['_pass']; $args['host'] = '[localhost | mail-server-IP]'; $args['cookiecheck'] = false; $args['valid'] = true; } return $args; } function is_localhost() { return true; // return $_SERVER['REMOTE_ADDR'] == '::1' || $_SERVER['REMOTE_ADDR'] == '127.0.0.1'; } }
Use a form like this one in your CMS page:
<form name="form" action="http://your.webmail.url/" method="post"> <input type="hidden" name="_action" value="login" /> <input type="hidden" name="_task" value="login" /> <input type="hidden" name="_autologin" value="1" /> <table> <tr> <td>Utente</td> <td><input name="_user" id="rcmloginuser" autocomplete="off" value="" type="text" /></td> </tr> <tr> <td>Password</td> <td><input name="_pass" id="rcmloginpwd" autocomplete="off" type="password" /></td> </tr> <tr> <td colspan="2"><input type="submit" value="Login" /></td> </tr> </table> </form>