|
|
@@ -11,6 +11,8 @@ use Opentalent\OtCore\Logging\OtLogger;
|
|
|
use Opentalent\OtCore\Service\OpentalentApiService;
|
|
|
use TYPO3\CMS\Core\Crypto\Random;
|
|
|
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\TimeTracker\TimeTracker;
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
use \TYPO3\CMS\Core\Authentication\AbstractAuthenticationService;
|
|
|
@@ -470,4 +472,43 @@ class OtAuthenticationService extends AbstractAuthenticationService
|
|
|
setcookie($name, '', 1, '/', $_SERVER['HTTP_HOST']); // for custom domains (not in .opentalent.fr)
|
|
|
setcookie($name, '', 1, '/', self::COOKIE_DOMAIN); // for opentalent.fr subdomains
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get a user from DB by username
|
|
|
+ *
|
|
|
+ * @param string $username User name
|
|
|
+ * @param string $extraWhere Additional WHERE clause: " AND ...
|
|
|
+ * @param array|string $dbUserSetup User db table definition, or empty string for $this->db_user
|
|
|
+ * @return mixed User array or FALSE
|
|
|
+ */
|
|
|
+ public function fetchUserRecordTemp($username, $extraWhere = '', $dbUserSetup = '')
|
|
|
+ {
|
|
|
+ $dbUser = is_array($dbUserSetup) ? $dbUserSetup : $this->db_user;
|
|
|
+ $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;
|
|
|
+ }
|
|
|
}
|