


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ä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


Comments (4)