Changeset 1168

Show
Ignore:
Timestamp:
11/18/08 23:20:20 (2 months ago)
Author:
laurentj
Message:

ticket #658: jauth~login:form should support auth_url_return in the form

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix-modules/jauth/controllers/login.classic.php

    r1024 r1168  
    2525        $url_return = '/'; 
    2626 
     27        // both after_login and after_logout config fields are required  
    2728        if ($conf['after_login'] == '') 
    2829            throw new jException ('jauth~autherror.no.auth_login'); 
     
    3132            throw new jException ('jauth~autherror.no.auth_logout'); 
    3233 
     34        // if after_login_override = off or url_return doesnt exists, set url_return to after_login    
     35        // if auth_url_return exists, redirect to it  
    3336        if (!($conf['enable_after_login_override'] && $url_return= $this->param('auth_url_return'))){ 
    3437            $url_return =  jUrl::get($conf['after_login']); 
     
    3639 
    3740        if (!jAuth::login($this->param('login'), $this->param('password'), $this->param('rememberMe'))){ 
     41            // auth fails 
    3842            sleep (intval($conf['on_error_sleep'])); 
    39             $url_return = jUrl::get($conf['after_logout'],array ('login'=>$this->param('login'), 'failed'=>1)); 
     43            $params = array ('login'=>$this->param('login'), 'failed'=>1); 
     44            if($conf['enable_after_login_override']) 
     45                $params['auth_url_return'] = $this->param('auth_url_return'); 
     46            $url_return = jUrl::get($conf['after_logout'],$params); 
    4047        } 
    4148 
     
    4855    * 
    4956    */ 
    50     function out (){ 
     57    function out(){ 
    5158        jAuth::logout(); 
    5259        $conf = $GLOBALS['gJCoord']->getPlugin ('auth')->config; 
     
    5562            throw new jException ('jauth~autherror.no.auth_logout'); 
    5663 
    57         if (!($conf['enable_after_logout_override'] && $url_return= $this->param('auth_url_return'))){ 
     64        if (!($conf['enable_after_logout_override'] && 
     65              $url_return = $this->param('auth_url_return'))) { 
    5866            $url_return =  jUrl::get($conf['after_logout']); 
    5967        } 
     68 
    6069        $rep = $this->getResponse('redirectUrl'); 
    6170        $rep->url = $url_return; 
     
    6776    */ 
    6877    function form() { 
     78        $conf = $GLOBALS['gJCoord']->getPlugin('auth')->config;  
    6979        if (jAuth::isConnected()) { 
    70             $conf = $GLOBALS['gJCoord']->getPlugin('auth')->config;  
    71  
    7280            if ($conf['after_login'] != '') { 
    73                 if (!($conf['enable_after_login_override'] && $url_return= $this->param('auth_url_return'))){  
     81                if (!($conf['enable_after_login_override'] && 
     82                      $url_return= $this->param('auth_url_return'))){  
    7483                    $url_return =  jUrl::get($conf['after_login']); 
    7584                } 
     
    8190 
    8291        $rep = $this->getResponse('html'); 
     92        $rep->title =  jLocale::get ('auth.titlePage.login'); 
     93        //$rep->bodyTpl = 'jauth~index'; 
    8394 
    84         $rep->title =  jLocale::get ('auth.titlePage.login'); 
    85         $rep->bodyTpl = 'jauth~index'; 
    86         $rep->body->assignZone ('MAIN', 'jauth~loginform', array ('login'=>$this->param('login'), 'failed'=>$this->param('failed'), 'showRememberMe'=>jAuth::isPersistant())); 
     95        $zp = array ('login'=>$this->param('login'), 
     96                     'failed'=>$this->param('failed'), 
     97                     'showRememberMe'=>jAuth::isPersistant()); 
     98 
     99        if ($conf['enable_after_login_override']) { 
     100            $zp['auth_url_return'] = $this->param('auth_url_return'); 
     101        } 
     102 
     103        $rep->body->assignZone ('MAIN', 'jauth~loginform', $zp); 
    87104        return $rep; 
    88105    } 
  • trunk/lib/jelix-modules/jauth/templates/login.form.tpl

    r1024 r1168  
    66{if ! $isLogged} 
    77 
    8 <form action="{jurl 'jauth~login:in'}" method="post" id="loginForm"> 
     8<form action="{formurl 'jauth~login:in'}" method="post" id="loginForm"> 
    99      <fieldset> 
    1010      <table> 
     
    2424       {/if} 
    2525       </table> 
     26       {formurlparam 'jauth~login:in'} 
     27       {if !empty($auth_url_return)} 
     28       <input type="hidden" name="auth_url_return" value="{$auth_url_return|eschtml}" /> 
     29       {/if} 
    2630       <input type="submit" value="{@jauth~auth.buttons.login@}"/> 
    2731       </fieldset> 
  • trunk/lib/jelix-modules/jauth/zones/loginform.zone.php

    r534 r1168  
    1616    protected function _prepareTpl(){ 
    1717 
    18         $this->_tpl->assign ('login', $this->getParam('login')); 
    19         $this->_tpl->assign ('failed',  $this->getParam('failed')); 
    20  
     18        $this->_tpl->assign ('login', $this->param('login')); 
     19        $this->_tpl->assign ('failed',  $this->param('failed')); 
     20        $this->_tpl->assign ('auth_url_return',  $this->param('auth_url_return', '')); 
     21          
    2122        $this->_tpl->assign ('user', jAuth::getUserSession()); 
    2223        $this->_tpl->assign ('isLogged', jAuth::isConnected()); 
  • trunk/lib/jelix/plugins/coord/auth/auth.coord.php

    r1026 r1168  
    119119                }else{ 
    120120                    if(!$badip){ 
     121                        $auth_url_return = $GLOBALS['gJCoord']->request->getParam('auth_url_return'); 
     122                        if($auth_url_return === null) 
     123                            $GLOBALS['gJCoord']->request->params['auth_url_return'] = jUrl::getCurrentUrl(); 
    121124                        $selector= new jSelectorAct($this->config['on_error_action']); 
    122125                    } 
Download in other formats: Unified Diff Zip Archive