1

I am using TYPO3 6.1 and try to login a FE user via Code (included via PHP and USER_INT).

This code does not work for me. :( Any ideas why?

// try to login the user now
$loginData = array(
    'uname'   => trim($postData['username']), //usernmae
    'uident'  => trim($postData['password']), //password
    'status'  => 'login'
);

// $GLOBALS['TSFE']->fe_user-checkPid=0; //do not use a particular pid
$GLOBALS['TSFE']->fe_user->checkPid = $this->feUserPid; // ''; //do not use a particular pid
$info = $GLOBALS['TSFE']->fe_user->getAuthInfoArray();

// 
$user = $GLOBALS['TSFE']->fe_user->fetchUserRecord(
    $info['db_user'], $loginData['uname']
);

$ok = $GLOBALS['TSFE']->fe_user->compareUident($user, $loginData);

//
if($ok) 
{        
    // login successfull
    $GLOBALS['TSFE']->fe_user->createUserSession($user);

    // 
    $content = '<h3 class="green">LOGIN OK!</h3>';
    $content .= '<p>Sie sind eingeloggt als ' . $feUsername . ' und wurden nun weitergeleitet...</p>';
} 
else 
{
    // login failed
    $content = '<h3 class="red">LOGIN FAILED!</h3>'; 
} 

Thanks for any hint!

2 Answers 2

0

Starting with TYPO3 4.7, you must use $loginData['uident_text'] instead of $loginData['uident'] for the password.

If the problem persists, please give more information what exactly is going wrong, what your log says etc.

2
  • Hi lorenz, when I use ['uident'], an entry is created in the fe_sessions table, but $GLOBALS['TSFE']->fe_user->user['username'] stays empty in my debug output. When using ['uident_text'], no entry in the fe_sessions table is created. Thanks for help
    – kk3003
    Dec 31, 2013 at 14:21
  • Anyone else an idea please?
    – kk3003
    Jan 2, 2014 at 12:00
0

Does compareUident() return TRUE for you? I, fx have a case, where I automatically log in user that has just created themselves. And compareUident() didn't work for me for some reason, but as I know this same website visitor just created the user, I skip that function and continue on initiating all the session variables. The following is a working code on TYPO3 6.1:

$loginData = array(
    'uname' => $postdata['username'],
    'uident' => $postdata['password'],
    'status' => 'login',
);
$GLOBALS['TSFE']->fe_user->checkPid = 0;
$info = $GLOBALS['TSFE']->fe_user->getAuthInfoArray();
$user = $GLOBALS['TSFE']->fe_user->fetchUserRecord($info['db_user'], $loginData['uname']);
//if($GLOBALS['TSFE']->fe_user->compareUident($user, $loginData)) {
$GLOBALS['TSFE']->fe_user->user = $GLOBALS['TSFE']->fe_user->fetchUserSession();
$GLOBALS['TSFE']->loginUser = 1;
$GLOBALS['TSFE']->fe_user->fetchGroupData(); 
$GLOBALS['TSFE']->fe_user->start();
$GLOBALS['TSFE']->fe_user->createUserSession($user);
$GLOBALS['TSFE']->fe_user->loginSessionStarted = TRUE;
//}

Inspired by:

https://stackoverflow.com/a/7738383/445364

https://typo3.org/extensions/repository/view/dix_easylogin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.