Changeset 2099 in ExiteCMS


Ignore:
Timestamp:
12/07/08 22:05:25 (3 years ago)
Author:
WanWizard
Message:

the authentication system now uses templates for login pages, so a new authentication method can supply it's own template with fields required for login

Location:
trunk
Files:
6 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/authentication/auth_local.php

    r2095 r2099  
    7272    } 
    7373 
     74    // get the template for this authentication method 
     75    function get_template($type = "side") { 
     76 
     77        if ($type == "side") { 
     78            return PATH_INCLUDES."authentication/templates/auth.username_password.side.tpl"; 
     79        } else { 
     80            return PATH_INCLUDES."authentication/templates/auth.username_password.body.tpl"; 
     81        } 
     82    } 
     83 
    7484    /*-----------------------------------------------+ 
    7585    | private class methods                          | 
  • trunk/includes/authentication/auth_openid.php

    r2095 r2099  
    9595    } 
    9696 
     97    // get the template for this authentication method 
     98    function get_template($type = "side") { 
     99 
     100        if ($type == "side") { 
     101            return PATH_INCLUDES."authentication/templates/auth.openid.side.tpl"; 
     102        } else { 
     103            return PATH_INCLUDES."authentication/templates/auth.openid.body.tpl"; 
     104        } 
     105    } 
     106 
    97107    /*-----------------------------------------------+ 
    98108    | private class methods                          | 
  • trunk/includes/authentication/authentication.php

    r2095 r2099  
    4545    // used to store the logon status code 
    4646    var $status = false; 
     47 
     48    // used to store the available logon templates 
     49    var $templates = array(); 
    4750 
    4851    // class constructor 
     
    139142 
    140143        // call the logoff function of the authentication method used 
    141         $this->classes[$this->method_used]->logoff(); 
     144        if ($this->method_used) { 
     145            $this->classes[$this->method_used]->logoff(); 
     146        } 
    142147 
    143148        // remove logon information from the session record 
     
    155160 
    156161        return $this->userrecord; 
     162    } 
     163 
     164    // get the list of templates 
     165    function get_templates($type = "side") { 
     166 
     167        // do we have them cached? 
     168        if (!isset($this->templates[$type]) || !is_array($this->templates[$type])) { 
     169            // define the array to store the templates for this type 
     170            $this->templates[$type] = array(); 
     171 
     172            // loop through the selected logon functions 
     173            foreach($this->selected as $method) { 
     174                // check if the class exists and is loaded 
     175                if (isset($this->methods[$method]) && is_object($this->classes[$method])) { 
     176                    // call the get_template function of the class 
     177                    $template = $this->classes[$method]->get_template($type); 
     178                    // do we already have this template 
     179                    if (!isset($this->templates[$type][$template])) { 
     180                        if (isset($_SESSION['box_login_'.$method])) { 
     181                            $state = $_SESSION['box_login_'.$method] == 0 ? 1 : 0; 
     182                        } else { 
     183                            $state = 1; 
     184                        } 
     185                        $this->templates[$type][$template] = array('method' => $method, 'state' => $state); 
     186                    } 
     187                } 
     188            } 
     189        } 
     190        // return the templates 
     191        return $this->templates[$type]; 
    157192    } 
    158193 
  • trunk/includes/templates/main.login.tpl

    r2095 r2099  
    2424        <meta http-equiv='refresh' content='{$refresh}; url={$url}'> 
    2525        <link href="{$smarty.const.THEME}exitecms__0001.css" rel="stylesheet" type="text/css" /> 
     26        <script type='text/javascript' src='{$smarty.const.INCLUDES}jscripts/core_functions__0001.js'></script> 
    2627    </head> 
    2728    <body class='body'> 
     
    3334                            <form name='loginform1' method='post' action='{$smarty.const.BASEDIR}setuser.php?login=yes'> 
    3435                                <img src='{$smarty.const.THEME}images/{$settings.sitebanner}' alt='{$settings.sitename}' style='width:480px;margin:5px;'/> 
    35                                 {foreach from=$auth_methods item=method key=i} 
    36                                     {if $method_count > 1} 
    37                                         {if $method == "ldap"} 
    38                                             <div class='side-label'> 
    39                                                 {$locale.069} {$method|upper} {$locale.061}: 
    40                                             </div> 
    41                                             <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
    42                                         {elseif $method == "ad"} 
    43                                             <div class='side-label'> 
    44                                                 {$locale.069} {$method|upper} {$locale.061}: 
    45                                             </div> 
    46                                             <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
    47                                         {elseif $method == "local"} 
    48                                             <div class='side-label'> 
    49                                                 {$locale.069} {$locale.061}: 
    50                                             </div> 
    51                                             <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
    52                                         {elseif $method == "openid"} 
    53                                             <div class='side-label'> 
    54                                                 {$locale.069} {$locale.067}: 
    55                                             </div> 
    56                                             <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
    57                                         {/if} 
    58                                     {/if} 
    59                                     <div style='padding:5px;'> 
    60                                     {if $method == "ldap"} 
    61                                         {$locale.061}: <input type='text' name='ldap_name' class='textbox' style='width:145px' /> 
    62                                         &nbsp;&nbsp;&nbsp; 
    63                                         {$locale.062}: <input type='password' name='ldap_pass' class='textbox' style='width:145px' /><br /> 
    64                                     {elseif $method == "ad"} 
    65                                         {$locale.061}: <input type='text' name='ad_name' class='textbox' style='width:145px' /> 
    66                                         &nbsp;&nbsp;&nbsp; 
    67                                         {$locale.062}: <input type='password' name='ad_pass' class='textbox' style='width:145px' /><br /> 
    68                                     {elseif $method == "local"} 
    69                                         {$locale.061}: <input type='text' name='user_name' class='textbox' style='width:145px' /> 
    70                                         &nbsp;&nbsp;&nbsp; 
    71                                         {$locale.062}: <input type='password' name='user_pass' class='textbox' style='width:145px' /><br /> 
    72                                     {elseif $method == "openid"} 
    73                                         <input type='text' name='user_openid_url' class='textbox' style='width:128px;background: url({$smarty.const.IMAGES}openid_small_logo.gif) no-repeat; padding-left: 18px;' /> 
    74                                         &nbsp;&nbsp;&nbsp; 
    75                                         <span class='small' style='font-size:90%;'>  <a href="http://{$settings.locale_code}.wikipedia.org/wiki/OpenID"  target="_blank">{$locale.068}</a></span><br /> 
    76                                     {/if} 
    77                                     </div> 
    78                                     {if $method_count > 1} 
    79                                         </div> 
    80                                     {/if}            
     36                                {foreach from=$auth_templates item=method key=i} 
     37                                    {include file=$i} 
    8138                                {/foreach} 
    82                                     <hr /> 
    83                                     <div style='text-align:center'> 
    84                                         <input type='checkbox' name='remember_me' value='yes' title='{$locale.063}' style='vertical-align:middle;'{if $remember_me|default:"no" == "yes"} checked="checked"{/if}/> 
    85                                         <input type='submit' name='login' value='{$locale.064}' class='button' /><br /> 
    86                                         <input type='hidden' name='javascript_check' value='n' /> 
    87                                     </div> 
    88                                 </form> 
     39                                <hr /> 
     40                                <div style='text-align:center'> 
     41                                    <input type='checkbox' name='remember_me' value='yes' title='{$locale.063}' style='vertical-align:middle;'{if $remember_me|default:"no" == "yes"} checked="checked"{/if}/> 
     42                                    <input type='submit' name='login' value='{$locale.064}' class='button' /><br /> 
     43                                    <input type='hidden' name='javascript_check' value='n' /> 
     44                                </div> 
     45                            </form> 
    8946                            {literal} 
    9047                            <script type='text/javascript'> 
  • trunk/login.php

    r2095 r2099  
    3939$variables['login_expiry']  = (iADMIN && isset($_SESSION['login_expire'])) ? time_system2local($_SESSION['login_expire']) : ""; 
    4040 
    41 // get which authentication to show 
    42 $variables['auth_methods'] = explode(",",$settings['authentication_selected']); 
    43 $variables['method_count'] = count($variables['auth_methods']); 
    44 $variables['auth_state'] = array(); 
    45 foreach($variables['auth_methods'] as $key => $method) { 
    46     if (isset($_SESSION['box_login'.$key])) { 
    47         $variables['auth_state'][] = $_SESSION['box_login'.$key] == 0 ? 1 : 0; 
    48     } else { 
    49         $variables['auth_state'][] = 1; 
    50     } 
    51 } 
     41// get the login templates to allow authentication 
     42$variables['auth_templates'] = $GLOBALS['cms_authentication']->get_templates("body"); 
    5243 
    5344// check if we need to display a registration link 
  • trunk/modules/user_info_panel/templates/modules.user_info_panel.tpl

    r2079 r2099  
    6565    </div> 
    6666    <form name='loginform1' method='post' action='{$smarty.const.BASEDIR}setuser.php?login=yes'> 
    67         {foreach from=$auth_methods item=method key=i} 
    68             {if $method_count > 1} 
    69                 {if $method == "ldap"} 
    70                     <div class='side-label'> 
    71                         <div style='display:inline; position:relative; float:right;margin-top:2px;'> 
    72                             <img src='{$smarty.const.THEME}images/panel_{if $auth_state.$i}off{else}on{/if}.gif' alt='' name='b_login{$i}' onclick="javascript:flipBox('login{$i}')" /> 
    73                         </div> 
    74                         {$locale.069} {$method|upper} {$locale.061}: 
    75                     </div> 
    76                     <div id='box_login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
    77                 {elseif $method == "ad"} 
    78                     <div class='side-label'> 
    79                         <div style='display:inline; position:relative; float:right;margin-top:2px;'> 
    80                             <img src='{$smarty.const.THEME}images/panel_{if $auth_state.$i}off{else}on{/if}.gif' alt='' name='b_login{$i}' onclick="javascript:flipBox('login{$i}')" /> 
    81                         </div> 
    82                         {$locale.069} {$method|upper} {$locale.061}: 
    83                     </div> 
    84                     <div id='box_login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
    85                 {elseif $method == "local"} 
    86                     <div class='side-label'> 
    87                         <div style='display:inline; position:relative; float:right;margin-top:2px;'> 
    88                             <img src='{$smarty.const.THEME}images/panel_{if $auth_state.$i}off{else}on{/if}.gif' alt='' name='b_login{$i}' onclick="javascript:flipBox('login{$i}')" /> 
    89                         </div> 
    90                         {$locale.069} {$locale.061}: 
    91                     </div> 
    92                     <div id='box_login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
    93                 {elseif $method == "openid"} 
    94                     <div class='side-label'> 
    95                         <div style='display:inline; position:relative; float:right;margin-top:2px;'> 
    96                             <img src='{$smarty.const.THEME}images/panel_{if $auth_state.$i}off{else}on{/if}.gif' alt='' name='b_login{$i}' onclick="javascript:flipBox('login{$i}')" /> 
    97                         </div> 
    98                         {$locale.069} {$locale.067}: 
    99                     </div> 
    100                     <div id='box_login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
    101                 {/if} 
    102             {/if} 
    103             <div style='padding-left:2px;'> 
    104             {if $method == "ldap"} 
    105                 {$locale.061}:<br /><input type='text' name='ldap_name' class='textbox' style='width:145px' /><br /> 
    106                 {$locale.062}:<br /><input type='password' name='ldap_pass' class='textbox' style='width:145px' /><br /> 
    107             {elseif $method == "ad"} 
    108                 {$locale.061}:<br /><input type='text' name='ad_name' class='textbox' style='width:145px' /><br /> 
    109                 {$locale.062}:<br /><input type='password' name='ad_pass' class='textbox' style='width:145px' /><br /> 
    110             {elseif $method == "local"} 
    111                 {$locale.061}:<br /><input type='text' name='user_name' class='textbox' style='width:145px' /><br /> 
    112                 {$locale.062}:<br /><input type='password' name='user_pass' class='textbox' style='width:145px' /><br /> 
    113             {elseif $method == "openid"} 
    114                 <input type='text' name='user_openid_url' class='textbox' style='width:128px;background: url({$smarty.const.IMAGES}openid_small_logo.gif) no-repeat; padding-left: 18px;' /><br /> 
    115                 <span class='small' style='font-size:90%;'>  <a href="http://{$settings.locale_code}.wikipedia.org/wiki/OpenID"  target="_blank">{$locale.068}</a></span><br /> 
    116             {/if} 
    117             </div> 
    118             {if $method_count > 1} 
    119                 </div> 
    120             {/if}            
     67        {foreach from=$auth_templates item=method key=i} 
     68            {include file=$i} 
    12169        {/foreach} 
    122             <hr /> 
    123             <div style='text-align:center'> 
    124                 <input type='checkbox' name='remember_me' value='yes' title='{$locale.063}' style='vertical-align:middle;'{if $remember_me|default:"no" == "yes"} checked="checked"{/if}/> 
    125                 <input type='submit' name='login' value='{$locale.064}' class='button' /><br /> 
    126                 <input type='hidden' name='javascript_check' value='n' /> 
    127             </div> 
    128         </form> 
     70        <hr /> 
     71        <div style='text-align:center'> 
     72            <input type='checkbox' name='remember_me' value='yes' title='{$locale.063}' style='vertical-align:middle;'{if $remember_me|default:"no" == "yes"} checked="checked"{/if}/> 
     73            <input type='submit' name='login' value='{$locale.064}' class='button' /><br /> 
     74            <input type='hidden' name='javascript_check' value='n' /> 
     75        </div> 
     76    </form> 
    12977    {literal} 
    13078    <script type='text/javascript'> 
  • trunk/modules/user_info_panel/user_info_panel.php

    r2095 r2099  
    7979$variables['login_expiry']  = isset($_SESSION['login_expire']) ? time_system2local($_SESSION['login_expire']) : ""; 
    8080 
    81 // get which authentication to show 
    82 $variables['auth_methods'] = $GLOBALS['cms_authentication']->selected; 
    83 $variables['method_count'] = count($variables['auth_methods']); 
    84 $variables['auth_state'] = array(); 
    85 foreach($variables['auth_methods'] as $key => $method) { 
    86     if (isset($_SESSION['box_login'.$key])) { 
    87         $variables['auth_state'][] = $_SESSION['box_login'.$key] == 0 ? 1 : 0; 
    88     } else { 
    89         $variables['auth_state'][] = 1; 
    90     } 
    91 } 
     81// get the login templates to allow authentication 
     82$variables['auth_templates'] = $GLOBALS['cms_authentication']->get_templates("side"); 
    9283 
    9384// check if we need to display a registration link 
Note: See TracChangeset for help on using the changeset viewer.