Skip to content
Snippets Groups Projects

Feature upgrade to typo3 10

Merged Kevin Ditscheid requested to merge feature_Upgrade-to-TYPO3-10 into master
73 files
+ 2300
831
Compare changes
  • Side-by-side
  • Inline
Files
73
@@ -33,6 +33,11 @@ use Google_Auth_Exception;
use Google_Client;
use SGalinski\SgAccount\Service\BaseService;
use TYPO3\CMS\Core\Authentication\AbstractUserAuthentication;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Service\AbstractService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
@@ -131,7 +136,7 @@ class AuthService extends AbstractService {
$email, $this->authenticationInformation['db_user']['checkPidList'], $returnUnconfirmed
);
if (!$userUid) {
$userRecord = $this->parentObject->fetchUserRecord(
$userRecord = $this->fetchUserRecord(
$this->authenticationInformation['db_user'], $email
);
} else {
@@ -143,6 +148,47 @@ class AuthService extends AbstractService {
return $userRecord;
}
/**
* Get a user from DB by username
* provided for usage from services
*
* @param array $dbUser User db table definition: $this->db_user
* @param string $username user name
* @param string $extraWhere Additional WHERE clause: " AND ...
* @return mixed User array or FALSE
*/
public function fetchUserRecord($dbUser, $username, $extraWhere = '') {
$user = false;
if ($username || $extraWhere) {
$query = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($dbUser['table']);
$query->getRestrictions()->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$constraints = array_filter([
QueryHelper::stripLogicalOperatorPrefix($dbUser['check_pid_clause']),
QueryHelper::stripLogicalOperatorPrefix($dbUser['enable_clause']),
QueryHelper::stripLogicalOperatorPrefix($extraWhere),
]);
if (!empty($username)) {
array_unshift(
$constraints,
$query->expr()->eq(
$dbUser['username_column'],
$query->createNamedParameter($username, \PDO::PARAM_STR)
)
);
}
$user = $query->select('*')
->from($dbUser['table'])
->where(...$constraints)
->execute()
->fetch();
}
return $user;
}
/**
* Authenticates the frontend user if a backend user requested it
*
@@ -155,10 +201,11 @@ class AuthService extends AbstractService {
* @throws \InvalidArgumentException
*/
public function authUser(array $userRecord) {
$tsfe = $this->getTyposcriptFrontendController();
if ($userRecord && GeneralUtility::_GP('viewasuser')) {
$tsfe->initializeBackendUser();
if ($tsfe->isBackendUserLoggedIn()) {
if (
GeneralUtility::makeInstance(Context::class)
->getPropertyFromAspect('backend.user', 'isLoggedIn', false)
) {
return 200;
}
}
Loading