Commit c86651de authored by Stefan Bublies's avatar Stefan Bublies
Browse files

Inject Anpassungen und Änderung von $GLOBALS[TYPO3_DB] zu doctrine-dbal

parent 63447d13
......@@ -27,6 +27,9 @@ namespace Dtihiorg\DtiHiorg\Controller;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
/**
* HiOrgServerLoginController
*/
......@@ -36,7 +39,7 @@ class HiOrgServerLoginController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
* hiOrgServerLoginRepository
*
* @var \Dtihiorg\DtiHiorg\Domain\Repository\HiOrgServerLoginRepository
* @inject
* @TYPO3\\CMS\\Extbase\\Annotation\\Inject
*/
protected $hiOrgServerLoginRepository = NULL;
......@@ -71,25 +74,46 @@ class HiOrgServerLoginController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
if(mb_substr( $sAusgabe ,0,2)== "OK") {
// Login erfolgreich. User ggf. anlegen:
$aHiorgUser = unserialize(base64_decode(mb_substr( $sAusgabe , 3)));
print_r($aHiorgUser);
$sUsername = 'hiorg_'.$sKuerzel.'_'.$aHiorgUser['username'];
$rVorhanden = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'fe_users', 'username="'.$sUsername.'" AND deleted=0');
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('fe_users');
$rVorhanden = $queryBuilder
->select('uid')
->from('fe_users')
->where(
$queryBuilder->expr()->eq('username', $queryBuilder->createNamedParameter($sUsername)),
$queryBuilder->expr()->eq('deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
$queryBuilder->expr()->eq('disable', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
);
if ($rVorhanden->num_rows==0) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('fe_users', array(
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$databaseConnectionForPages = $connectionPool->getConnectionForTable('fe_users');
$databaseConnectionForPages->insert(
'fe_users',
[
'username' => $sUsername,
'usergroup' => $iFEGroup,
'pid' => $iUserStorage,
'crdate' => time(),
));
]
);
}
$sPasswort = rand(0,1000000).time();
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'username="'.$sUsername.'"', array(
'password' => md5($sPasswort),
'first_name' => $aHiorgUser['vorname'],
'name' => $aHiorgUser['name'],
'email' => $aHiorgUser['email'],
));
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('fe_users');
$queryBuilder
->update('fe_users')
->where(
$queryBuilder->expr()->eq('username', $queryBuilder->createNamedParameter($sUsername))
)
->set('password', md5($sPasswort))
->set('first_name', $aHiorgUser['vorname'])
->set('name', $aHiorgUser['name'])
->set('email', $aHiorgUser['email'])
->execute();
$loginData=array(
'uname' => $sUsername,
'uident' => $sPasswort,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment