+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3
Results 21 to 25 of 25

Thread: Ajax Login und Logout Weiterleitung?

  1. #21
    rundkubus is offline Registered User
    Join Date
    Dec 2009
    Posts
    12
    Downloads
    0
    Uploads
    0

    Default

    Wenn man sich via Ajax Form eingelogt (mit cookie[ajax_login]) und in Roundcube oben rechts auf den Logout-Link klickt, erfolgt der Logout ja "manuell" (statt automatisch aufgrund eines Inaktivitaet Timeouts).

  2. #22
    rosali's Avatar
    rosali is offline Super Moderator
    Join Date
    Dec 2007
    Location
    Germany
    Posts
    2,394
    Downloads
    36
    Uploads
    0

    Default

    OK ...

    Dann geht das eben alles innerhalb 'login_page' mit einem Check $rcmail->task == "logout" ... Probier ich morgen ... außer Du bist scheller
    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

  3. #23
    rosali's Avatar
    rosali is offline Super Moderator
    Join Date
    Dec 2007
    Location
    Germany
    Posts
    2,394
    Downloads
    36
    Uploads
    0

    Default

    Hoffentlich diesesmal ...

    PHP Code:
    <?php
    /**
     * Redirect on logout / optionally lock login page
     *
     * @version 1.0 - 31.12.2009
     * @author Roland 'rosali' Liebl
     * @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 'sessionerror';

      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('kill_session', array($this,'kill_session'));
      }
      
      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 
    kill_session($args)
      {      
        if(
    $_COOKIE['ajax_login'] == 1){
          
    setcookie ('ajax_login','',time()-3600);    
          
    $this->msg 'loggedout';
          
    $rcmail rcmail::get_instance();
          
    header("Location: " $rcmail->config->get('logout_redirect_url') . "msg=" urlencode(rcube_label($this->msg)));
          exit;    
        }
            
        return 
    $args;
      }
      
      function 
    login_page($p)
      {   
        if(
    $p['template'] == 'login' && $_COOKIE['ajax_login'] == 1){  
          
    setcookie ('ajax_login','',time()-3600);
          
    $rcmail rcmail::get_instance();           
          
    header("Location: " $rcmail->config->get('logout_redirect_url') . "msg=" urlencode(rcube_label($this->msg)));
          exit;
        }

        return 
    $p;
      }
    }
    ?>
    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

  4. #24
    rundkubus is offline Registered User
    Join Date
    Dec 2009
    Posts
    12
    Downloads
    0
    Uploads
    0

    Default

    @ rosali

    WOW, Du bist der Hammer. Nach ersten Tests sieht das super aus. Danke!
    Ich kann mich via eigenem-Ajax und normalem-Loginform einloggen und alles leitet nun genauso zurueck wie es gedacht war.
    Ich hätte das allein nie hinbekommen.

    NACHTRAG: Hier meine Version...
    (hoffe Du bist nicht boese wegen meiner Reduktion aufs wesentliche)

    PHP Code:
    <?php 
    /** 
     * Redirect on logout (if ajax login)
     * 
     * @version 1.1 - 02.01.2010 
     * @author Roland 'rosali' Liebl 
     * @website http://myroundcube.googlecode.com 
     * @licence GNU GPL 
     * 
     **/ 
      
    class logout_redirect extends rcube_plugin 
    {
        function 
    init()
        {
            
    $this->add_hook('render_page', array($this,'login_page')); 
            
    $this->add_hook('login_after', array($this,'login_after')); 
            
    $this->add_hook('kill_session', array($this,'kill_session')); 
        } 
        
        function 
    goto_url($v)
        { 
            
    setcookie ('ajax_login','',time()-3600);
            
    header('Location: http://domain123.net?log=' $v);
            exit;
        } 
        
        
    // ajax cookie
        
    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
        } 
        
        
    // user logout
        
    function kill_session($args
        {       
            if (
    $_COOKIE['ajax_login'] == 1)
                
    $this->goto_url('user');
            return 
    $args;
        }
        
        
    // auto logout (session errror)
        
    function login_page($p
        {    
            if (
    $_COOKIE['ajax_login'] == && $p['template'] == 'login')
                
    $this->goto_url('auto');
            return 
    $p;
        }

    ?>
    Last edited by rundkubus; 01-02-2010 at 09:49 PM.

  5. #25
    rosali's Avatar
    rosali is offline Super Moderator
    Join Date
    Dec 2007
    Location
    Germany
    Posts
    2,394
    Downloads
    36
    Uploads
    0

    Default

    Bis auf die hart kodierte URL werde ich Deine Änderungen übernehmen. Die Benutzer meiner Plugins sind es nicht gewöhnt in der plugin.php zu editieren.
    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

+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts