[TYPO3] Automatic FE user creation and auto-login

Lasse Guldsborg lasse at clioonline.dk
Mon Oct 1 13:58:07 CEST 2007


Hi list!

I'm making and extension to auto-login FE users by URL.
If the URL contains certain parameters a new FE user is created and logged 
in.

Below is the part of the code, where the user i created and logged in. It 
works, but it's not too smooth. The whole page is loaded before it reloads 
and logs in the new user.

Is there a better way? A way in which the user is logged in immediately upon 
creation.. before the HTML content starts generating.

Any help and/or comments are appreciated! :o)

Best regards,
Lasse

------------------------------------------

# Create user
$query = 'insert into fe_users (pid, tstamp, username, password, usergroup, 
endtime, name, crdate)
  values (
    "314",
    "'.$time.'",
    "'.mysql_escape_string($username).'",
    "'.mysql_escape_string($password).'",
    "10",
    "'.($endtime).'",
    "'.mysql_escape_string($_GET['userid']).'",
    "'.$time.'")';
$GLOBALS["TYPO3_DB"]->sql_query($query) or die($query."\n\n".mysql_error());

# login the new user
$content .= '
<form method="post" id="fe_cfu_user_login_form" 
action="'.$this->pi_getPageLink($GLOBALS["TSFE"]->id).'">
  <input type="hidden" id="user" name="user" value="'.$username.'" />
  <input type="hidden" id="pass" name="pass" value="'.$password.'" />
  <input type="hidden" name="logintype" value="login" />
  <input type="hidden" name="pid" value="314" />
</form>
<script type="text/javascript">
  document.getElementById("fe_cfu_user_login_form").submit();
</script>';

return $content; 




More information about the TYPO3-english mailing list