TypoScript Loginbox (using kb_md5feuser and newloginbox)

Submitting your vote...
Rating: 2.0 of 5. 3 vote(s).
Click the rating bar to rate this item.

This snippet shows how to create a loginbox using TypoScript. This Loginbox works with md5 passwords (ext: md5feuser) and the new loginbox extension.

 

 

#check if there is a logged in user (a feuser has to belog atleast to one usergroup) p
[usergroup=*]

#Logoff form with username
lib.login = COA_INT
lib.login {
  10 = TEXT
  10.wrap = <span id="logoutUName">|</span>
   
  20 = TEXT
  20.typolink.parameter = {$plugin.tx_newloginbox.loginUID}
  20.typolink.returnLast = url
  20.wrap = <form action="|" method="post">
   
  30 = COA
  30 {
    5 = TEXT
    5.wrap = <input type="submit" id="logout" value="|" />
     
    10 = TEXT
    10.value = <input type="hidden" name="logintype" value="logout" />
    20 = TEXT
    20.value = <input type="hidden" name="redirect_url" value="" />
    30 = TEXT
    30.value = </form>
  }
}

# if no user is logged in we show the loginform
[else]

# Important we can only get the challenge value from kb_md5feuser only through a php script 
includeLibs.md5fepw = fileadmin/scripts/md5fepw.php
lib.login = COA_INT
lib.login {
  10 = TEXT
  10.typolink.parameter = {$plugin.tx_newloginbox.loginUID}
  10.typolink.returnLast = url
  10.wrap = <form action="|" method="post" onsubmit="superchallenge_pass(this); return true;">
   
  # form
  20 = COA
  20 {
    10 = TEXT
    10.value = Login
    10.wrap = <input type="text" name="user" onclick="this.value=''" value="|" /> <br />
    20 = TEXT
    20.wrap = <input type="password" name="pass" onclick="this.value=''" value="|" />
     
    30 = COA
    30 {
      10 = TEXT
      10.value = <input type="hidden" name="logintype" value="login" />
      20 = TEXT
      20.value = {$plugin.tx_newloginbox.storageUID}
      20.wrap = <input type="hidden" name="pid" value="|" />
       
      # Call the PHP - Script
      25 = USER
      25.userFunc = user_md5fepw->md5Challenge
       
      30 = TEXT
      30.value = <button type="submit"><img src="fileadmin/templates/res/pictures/go.gif" alt="login" /></button>
      40 = TEXT
      40.value = </form>
    }
  }
}
[usergroup]

#Select the content for the loginbox in the correct language  (in this expamle english and german)
[usergroup=*] AND [globalVar = GP:L = {$langUID_EN}]
lib.login.10.value = Hello <!--###USERNAME###-->
lib.login.30.5.value = press to logout
[else]
lib.login.10.value = Hallo <!--###USERNAME###-->
lib.login.30.5.value = zum abmelden best&auml;tigen
[global]

# show the login only on a certain page and subpages
[PIDinRootline={$siteIntern}]
lib.login.if.isTrue = 1

# enable login if the constant activateLogin = 1
[else]
lib.login.if.isTrue = {$activateLogin}
[global]

 

Here the php script. The function is copied from kb_md5feuser and slightly modified

 


<?php
class user_md5fepw {
function 
md5Challenge($content$conf)
{
$js '
function superchallenge_pass(form) {
var pass = form.pass.value;
if (pass) {
form.pass.value = MD5(form.user.value + ":" + MD5(pass) + ":" + form.challenge.value);
return true;
} else
return false;
}'
;

$GLOBALS['TSFE']->JSCode .= $js;
$GLOBALS['TSFE']->additionalHeaderData['tx_kbmd5fepw_newloginbox'] = '<script language="JavaScript" type="text/javascript" src="typo3/md5.js"></script>';
$chal_val md5(time().getmypid());
$res $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_kbmd5fepw_challenge', array('challenge' => $chal_val'tstamp' => time()));
return 
'<input type="hidden" name="challenge" value="'.$chal_val.'">';
}
}
?> 

 

 

This snippet was submitted by Stefan Galinski


Top 10 Updates

Using Transparent PNG's in IE5/6 without JavaScript geändert am  04-Oct-2008 12:27:15
Using lightbox without extension geändert am  13-Jun-2008 14:20:51
Custom field for GMENU alt text geändert am  13-Jun-2008 13:58:07
Extending typoscript properties with stdWrap geändert am  13-Jun-2008 13:54:32
Create menus using data from other tables than "pages" V2  geändert am  24-Mar-2008 13:02:09
Login geändert am  17-Mar-2008 12:47:52
Forum geändert am  17-Mar-2008 10:07:47
Who is Typo3wizard.com geändert am  26-Dec-2007 16:07:32
Menu as un-nested lists (iphone navigation) geändert am  29-Oct-2007 15:05:53
IF Conditions with AND and OR operators geändert am  16-Oct-2007 19:16:04
Deutsch
Search: