Changeset 1559 in ExiteCMS


Ignore:
Timestamp:
07/30/08 18:35:15 (4 years ago)
Author:
hverton
Message:

updated preliminary support for multiple authentication methods. Made it more modulair and flexible, so other methods can be added. Also the login panel is more user friendly now

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/administration/settings_security.php

    r1558 r1559  
    4444        $auth_local = $_POST['auth_method']{1} == "+" ? "1" : "0"; 
    4545        switch ($auth_method) { 
     46            case "0":   // Local only 
     47                $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = 'local' WHERE cfg_name = 'auth_type'"); 
     48                break; 
    4649            case "1":   // LDAP 
    4750                if ($auth_local) { 
     
    6063            case "3":   // OpenID 
    6164                if ($auth_local) { 
    62                     $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = 'openid,local' WHERE cfg_name = 'auth_type'"); 
     65                    $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = 'local,openid' WHERE cfg_name = 'auth_type'"); 
    6366                } else { 
    6467                    $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = 'openid' WHERE cfg_name = 'auth_type'"); 
     
    106109 
    107110// determine the auth_method defined 
    108 $auth_methods = explode(",",$settings2['auth_type'].","); 
    109 switch($auth_methods[0]) { 
    110     case "ldap": 
    111         $auth_method = 1; 
    112         break; 
    113     case "ad": 
    114         $auth_method = 2; 
    115         break; 
    116     case "openid": 
    117         $auth_method = 3; 
    118     case "local": 
    119         break; 
    120     default: 
    121         $auth_method = 0; 
     111$auth_methods = explode(",",$settings2['auth_type']); 
     112$auth_method = 0; 
     113$auth_local = false; 
     114foreach($auth_methods as $auth_method) { 
     115    switch($auth_method) { 
     116        case "ldap": 
     117            $auth_method = 1; 
     118            break; 
     119        case "ad": 
     120            $auth_method = 2; 
     121            break; 
     122        case "openid": 
     123            $auth_method = 3; 
     124        case "local": 
     125            $auth_local = true; 
     126            break; 
     127        default: 
     128            $auth_method = 0; 
     129    } 
    122130} 
    123 $variables['auth_method'] = $auth_method; 
    124131 
    125132// check if a local fallback is defined 
    126 if ($auth_method && $auth_methods[1] == "local") { 
    127     $variables['auth_method'] .= "+"; 
    128 } 
     133$variables['auth_method'] .= $auth_method . ($auth_local ? "+" : " "); 
    129134 
    130135// define the admin body panel 
  • trunk/administration/tools/language_pack_English.php

    r1558 r1559  
    26652665        $localestrings['066'] = "Forgotten your password?<br />Request a new one <a href='%slostpassword.php' class='side'>here</a>."; 
    26662666        $localestrings['067'] = "OpenID URL"; 
    2667         $localestrings['068'] = "Get an OpenID"; 
    2668         $localestrings['069'] = "Info"; 
     2667        $localestrings['068'] = "What is an OpenID?"; 
     2668        $localestrings['069'] = "with"; 
    26692669        $localestrings['070'] = "Online"; 
    26702670        $localestrings['071'] = "< 5 mins"; 
  • trunk/administration/tools/language_pack_Nederlands.php

    r1558 r1559  
    26512651        $localestrings['066'] = "Wachtwoord vergeten?<br />Vraag <a href='%slostpassword.php' class='side'>hier</a> een nieuwe aan."; 
    26522652        $localestrings['067'] = "OpenID URL"; 
    2653         $localestrings['068'] = "OpenID aanmaken"; 
    2654         $localestrings['069'] = "Info"; 
     2653        $localestrings['068'] = "Wat is een OpenID?"; 
     2654        $localestrings['069'] = "via"; 
    26552655        $localestrings['070'] = "Online"; 
    26562656        $localestrings['071'] = "< 5 mins"; 
  • trunk/files/locales/en.main.global.php

    r1558 r1559  
    33// locale       : English 
    44// locale name  : main.global 
    5 // generated on : Wed Jul 30 2008, 0:23:10 CEST 
     5// generated on : Wed Jul 30 2008, 17:51:24 CEST 
    66// translators  : ExiteCMS team,WanWizard 
    77// ---------------------------------------------------------- 
     
    6767$locale['066'] = "Forgotten your password?<br />Request a new one <a href='%slostpassword.php' class='side'>here</a>."; 
    6868$locale['067'] = "OpenID URL"; 
    69 $locale['068'] = "Get an OpenID"; 
    70 $locale['069'] = "Info"; 
     69$locale['068'] = "What is an OpenID?"; 
     70$locale['069'] = "with"; 
    7171$locale['070'] = "Online"; 
    7272$locale['071'] = "< 5 mins"; 
  • trunk/modules/user_info_panel/templates/modules.user_info_panel.tpl

    r1558 r1559  
    5959    <div style='text-align:center'> 
    6060        {$loginerror|default:""} 
    61         <form name='loginform' method='post' action='{$smarty.const.FUSION_SELF}'> 
    62             {if $auth_userpass} 
    63                 {$locale.061}<br /><input type='text' name='user_name' class='textbox' style='width:125px' /><br /> 
    64                 {$locale.062}<br /><input type='password' name='user_pass' class='textbox' style='width:125px' /><br /> 
     61    </div> 
     62    <form name='loginform' method='post' action='{$smarty.const.FUSION_SELF}'> 
     63        {foreach from=$auth_methods item=method key=i} 
     64            {if $method_count > 1} 
     65                {if $method == "ldap"} 
     66                    <div class='side-label'> 
     67                        <div style='display:inline; position:relative; float:right;margin-top:2px;'> 
     68                            <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}')" /> 
     69                        </div> 
     70                        {$locale.069} {$method|upper} {$locale.061}: 
     71                    </div> 
     72                    <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
     73                {elseif $method == "ad"} 
     74                    <div class='side-label'> 
     75                        <div style='display:inline; position:relative; float:right;margin-top:2px;'> 
     76                            <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}')" /> 
     77                        </div> 
     78                        {$locale.069} {$method|upper} {$locale.061}: 
     79                    </div> 
     80                    <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
     81                {elseif $method == "local"} 
     82                    <div class='side-label'> 
     83                        <div style='display:inline; position:relative; float:right;margin-top:2px;'> 
     84                            <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}')" /> 
     85                        </div> 
     86                        {$locale.069} {$locale.061}: 
     87                    </div> 
     88                    <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
     89                {elseif $method == "openid"} 
     90                    <div class='side-label'> 
     91                        <div style='display:inline; position:relative; float:right;margin-top:2px;'> 
     92                            <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}')" /> 
     93                        </div> 
     94                        {$locale.069} {$locale.067}: 
     95                    </div> 
     96                    <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
     97                {/if} 
    6598            {/if} 
    66             {if $auth_openid} 
    67                 {$locale.067}<br /><input type='text' name='user_openid_url' class='textbox' style='width:108px;background: url({$smarty.const.IMAGES}openid_small_logo.png) no-repeat; padding-left: 18px;' /><br /> 
    68                 <span class='small' style='font-size:90%;'>  <a href="http://openid.net/get/"  target="_blank">{$locale.068}</a> &middot; <a href="http://openid.net/what" target="_blank">{$locale.069}</a></span><br /> 
     99            <div style='padding-left:2px;'> 
     100            {if $method == "ldap"} 
     101                {$locale.061}:<br /><input type='text' name='ldap_name' class='textbox' style='width:145px' /><br /> 
     102                {$locale.062}:<br /><input type='password' name='ldap_pass' class='textbox' style='width:145px' /><br /> 
     103            {elseif $method == "ad"} 
     104                {$locale.061}:<br /><input type='text' name='ad_name' class='textbox' style='width:145px' /><br /> 
     105                {$locale.062}:<br /><input type='password' name='ad_pass' class='textbox' style='width:145px' /><br /> 
     106            {elseif $method == "local"} 
     107                {$locale.061}:<br /><input type='text' name='user_name' class='textbox' style='width:145px' /><br /> 
     108                {$locale.062}:<br /><input type='password' name='user_pass' class='textbox' style='width:145px' /><br /> 
     109            {elseif $method == "openid"} 
     110                <input type='text' name='user_openid_url' class='textbox' style='width:128px;background: url({$smarty.const.IMAGES}openid_small_logo.png) no-repeat; padding-left: 18px;' /><br /> 
     111                <span class='small' style='font-size:90%;'>  <a href="http://en.wikipedia.org/wiki/OpenID"  target="_blank">{$locale.068}</a></span><br /> 
    69112            {/if} 
    70             <br /> 
    71             <input type='submit' name='login' value='{$locale.064}' class='button' /> 
    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}/><br /> 
    73             <input type='hidden' name='javascript_check' value='n' /> 
     113            </div> 
     114            {if $method_count > 1} 
     115                </div> 
     116            {/if}            
     117        {/foreach} 
     118            <hr /> 
     119            <div style='text-align:center'> 
     120                <input type='submit' name='login' value='{$locale.064}' class='button' /> 
     121                <input type='checkbox' name='remember_me' value='yes' title='{$locale.063}' style='vertical-align:middle;'{if $remember_me|default:"no" == "yes"} checked="checked"{/if}/><br /> 
     122                <input type='hidden' name='javascript_check' value='n' /> 
     123            </div> 
    74124        </form> 
    75     </div> 
    76 {literal} 
    77 <script type='text/javascript'> 
    78 /* <![CDATA[ */ 
    79     if (document.loginform.javascript_check.value == 'n') 
    80     { 
    81         document.loginform.javascript_check.value = 'y'; 
    82     } 
    83     /* ]]> */ 
    84 </script> 
    85 {/literal} 
    86125    {if $show_reglink || $show_passlink} 
    87126        <hr /> 
  • trunk/modules/user_info_panel/user_info_panel.php

    r1558 r1559  
    6969$variables['login_expiry']  = (iADMIN && isset($_SESSION['login_expire'])) ? time_system2local($_SESSION['login_expire']) : ""; 
    7070 
    71 // check which authentication to show 
    72 $auth_methods = explode(",",$settings['auth_type'].","); 
    73 switch($auth_methods[0]) { 
    74     case "local": 
    75     case "ldap": 
    76     case "ad": 
    77         $variables['auth_userpass'] = 1; 
    78         break; 
    79     default: 
    80         $variables['auth_userpass'] = 0; 
    81 } 
    82 switch($auth_methods[0]) { 
    83     case "openid": 
    84         $variables['auth_openid'] = 1; 
    85         break; 
    86     default: 
    87         $variables['auth_openid'] = 0; 
    88 } 
    89 switch($auth_methods[1]) { 
    90     case "local": 
    91         $variables['auth_userpass'] = 1; 
    92         break; 
    93     default: 
    94         break; 
     71// get which authentication to show 
     72$variables['auth_methods'] = explode(",",$settings['auth_type']); 
     73$variables['method_count'] = count($variables['auth_methods']); 
     74$variables['auth_state'] = array(); 
     75foreach($variables['auth_methods'] as $key => $method) { 
     76    $variables['auth_state'][] = isset($_SESSION['box_login'.$key]) && $_SESSION['box_login'.$key] == 0; 
    9577} 
    9678 
Note: See TracChangeset for help on using the changeset viewer.