Ich gehe davon aus, dass Deine User die Roundcube Login Page niemals zu Gesicht bekommen sollen.
Wenn das richtig ist, dann benutze das anhängende Plugin.
@ rosali
Besten Dank fuer Deinen super Einsatz!
Eine kleine Frage habe ich noch, wie kann ich feststellen ob der Logout vom User
manuell oder vom System automatisch (aufgrund eines Timeouts) vollzogen wurde?
Das wuerde ich gerne in der redirect-url domain/?log=xxx mitgeben.
xxx = "user" _oder_ "auto"
Last edited by rundkubus; 12-30-2009 at 05:47 PM.
Ich gehe davon aus, dass Deine User die Roundcube Login Page niemals zu Gesicht bekommen sollen.
Wenn das richtig ist, dann benutze das anhängende Plugin.
Regards,
Rosali
__________________
MyRoundcube Project http://myroundcube.googlecode.com
MyRoundcube Online Demo - Free Email Address http://mail4us.net
MyRoundcube Plugins Generic Installation Guide http://mail4us.net/myroundcube/index.php
Mailing List http://mail4us.net/?_action=plugin.nabble
Könntest Du bitte Dein AJAX Login Script posten?
Regards,
Rosali
__________________
MyRoundcube Project http://myroundcube.googlecode.com
MyRoundcube Online Demo - Free Email Address http://mail4us.net
MyRoundcube Plugins Generic Installation Guide http://mail4us.net/myroundcube/index.php
Mailing List http://mail4us.net/?_action=plugin.nabble
@ rosali
Zuerst: Es sollte auch weiterhin moeglich sein, sich ueber das "normale" Loginform einzuloggen. Manche bevorzugen einen neutrales Loginform statt meine Portalseite.
Das ein Ajax Login via $_POST[ajax] in der Roundcube Session registriert und beim Logout entsprechend beachtet wird (ein Switch ob ein eigener Redirect greift oder nicht), fehlt aber noch.
Anbei eine Standalone Version des HTML/jQuery Login Scripts (muss nach .html umbenannt werden).
Frage:
Verstehe ich das richtig, das in Deinem logout_redirect.php Script bei einem Session Timeout die Funktion login_page() greift?
Gruss Rundkubus
Last edited by rundkubus; 12-31-2009 at 12:41 PM.
Ich sehe keinen Hook, der bei einem Timeout benutzt werden könnte. Allerdings wird bei einem Timeout auf die Login Page umgeleitet. Insoweist ist die Antwort also "ja". Zu beachten ist aber, dass meine Methode die Login Page komplett sperrt.
Regards,
Rosali
__________________
MyRoundcube Project http://myroundcube.googlecode.com
MyRoundcube Online Demo - Free Email Address http://mail4us.net
MyRoundcube Plugins Generic Installation Guide http://mail4us.net/myroundcube/index.php
Mailing List http://mail4us.net/?_action=plugin.nabble
@ rosali
Frohes Neues!
Danke fuer die Info. Ist es den moeglich die Funktion login_page() nur auszufuehren,
wenn zuvor mit $_POST[ajax] eingeloggt wurde?
Also das wir eine entspr. Session Var benutzen um das zu checken?
Mit einer Session Variable dürfte es nicht gehen, da die Session ja nicht mehr zur Verfügung steht, wenn ein Timeout erfolgte. Es müsste aber mit einem Cookie gehen.
Regards,
Rosali
__________________
MyRoundcube Project http://myroundcube.googlecode.com
MyRoundcube Online Demo - Free Email Address http://mail4us.net
MyRoundcube Plugins Generic Installation Guide http://mail4us.net/myroundcube/index.php
Mailing List http://mail4us.net/?_action=plugin.nabble
PHP Code:<?php
/**
* Redirect on logout / optionally lock login page
*
* @version 1.0 - 31.12.2009
* @author 'rosali'
* @website http://myroundcube.googlecode.com
* @licence GNU GPL
*
**/
/** USAGE
*
* #1- Copy "logout_redirect/config/config.inc.php.dist" to "config.inc.php"
* #2- Configure "logout_redirect/config/config.inc.php".
* #3- Register plugin ("./config/main.inc.php ::: $rcmail_config['plugins']").
*
**/
class logout_redirect extends rcube_plugin
{
private $msg = 'loggedout';
function init()
{
if(file_exists("./plugins/logout_redirect/config/config.inc.php"))
$this->load_config('config/config.inc.php');
else
$this->load_config('config/config.inc.php.dist');
$this->add_hook('render_page', array($this, 'login_page'));
$this->add_hook('login_after', array($this,'login_after'));
$this->add_hook('logout_after', array($this,'logout_after'));
}
function login_after($args)
{
if(!empty($_POST['ajax']))
setcookie ('ajax_login',1,time()+60*60*24*365);
else
setcookie ('ajax_login','',time()-3600);
return $args;
}
function login_page($p)
{
$rcmail = rcmail::get_instance();
if($p['template'] == 'login' && $rcmail->config->get('lock_login_page') == TRUE && $_COOKIE['ajax_login'] == 1){
$this->msg = 'sessionerror';
header("Location: " . $rcmail->config->get('logout_redirect_url') . "?msg=" . urlencode(rcube_label($this->msg)));
exit;
}
setcookie ('ajax_login','',time()-3600);
return $p;
}
function logout_after($args)
{
$rcmail = rcmail::get_instance();
header("Location: " . $rcmail->config->get('logout_redirect_url') . "?msg=" . urlencode(rcube_label($this->msg)));
return $args;
}
}
?>
Regards,
Rosali
__________________
MyRoundcube Project http://myroundcube.googlecode.com
MyRoundcube Online Demo - Free Email Address http://mail4us.net
MyRoundcube Plugins Generic Installation Guide http://mail4us.net/myroundcube/index.php
Mailing List http://mail4us.net/?_action=plugin.nabble
@ Rosali
NACHTRAG:
--------------------------
ich hätte erstmal richtig testen sollen.... es funktioniert fast:
Denn bei einem manuellen Ajax Logout greift "login_page()=>auto" zuerst statt "logout_after()=>user",
was ja in meinem Fall falsch ist, da login_page() _nur_ bei einem Timeout greifen soll.
--------------------------
VIELEN HERZLICHEN DANK fuer Deinen Code, es funktioniert!
Ich habe das wie folgt fuer mich geaendert...
- $msg entfernt und user/auto direkt in header() gesetzt
- login_page() if abfrage um !$_POST['ajax'] erweitert
- logout_after() if abfrage mit $_COOKIE['ajax_login']==1 hinzugefuegt
- login_page() "lock_login_page==true" auf if abfrage auskommentiert
PHP Code:<?php
/**
* Redirect on logout / optionally lock login page
*
* @version 1.0 - 31.12.2009
* @author 'rosali'
* @website http://myroundcube.googlecode.com
* @licence GNU GPL
*
**/
/** USAGE
*
* #1- Copy "logout_redirect/config/config.inc.php.dist" to "config.inc.php"
* #2- Configure "logout_redirect/config/config.inc.php".
* #3- Register plugin ("./config/main.inc.php ::: $rcmail_config['plugins']").
*
**/
class logout_redirect extends rcube_plugin
{
function init()
{
if(file_exists("./plugins/logout_redirect/config/config.inc.php"))
$this->load_config('config/config.inc.php');
else
$this->load_config('config/config.inc.php.dist');
$this->add_hook('render_page', array($this, 'login_page'));
$this->add_hook('login_after', array($this,'login_after'));
$this->add_hook('logout_after', array($this,'logout_after'));
}
function login_after($args)
{
if(!empty($_POST['ajax']))
setcookie ('ajax_login',1,time()+60*60*24*365);
else
setcookie ('ajax_login','',time()-3600);
return $args;
}
function login_page($p)
{
$rcmail = rcmail::get_instance();
if($p['template'] == 'login' && !$_POST['ajax'] && $_COOKIE['ajax_login'] == 1){ // && $rcmail->config->get('lock_login_page') == TRUE
setcookie ('ajax_login','',time()-3600);
header("Location: " . $rcmail->config->get('logout_redirect_url') . 'auto');
exit;
}
return $p;
}
function logout_after($args)
{
$rcmail = rcmail::get_instance();
if ($_COOKIE['ajax_login'] == 1)
header("Location: " . $rcmail->config->get('logout_redirect_url') . 'user');
return $args;
}
}
?>
Last edited by rundkubus; 01-02-2010 at 03:03 PM.
Was meinst Du mit "manuellem AJAX Logout"?
Regards,
Rosali
__________________
MyRoundcube Project http://myroundcube.googlecode.com
MyRoundcube Online Demo - Free Email Address http://mail4us.net
MyRoundcube Plugins Generic Installation Guide http://mail4us.net/myroundcube/index.php
Mailing List http://mail4us.net/?_action=plugin.nabble
There are currently 1 users browsing this thread. (0 members and 1 guests)