113 parent::__construct();
117 $this->dontSetCookie =
true;
120 $this->get_name =
'ftu';
121 $this->loginType =
'FE';
122 $this->user_table =
'fe_users';
123 $this->username_column =
'username';
124 $this->userident_column =
'password';
125 $this->userid_column =
'uid';
126 $this->lastLogin_column =
'lastlogin';
127 $this->enablecolumns = [
128 'deleted' =>
'deleted',
129 'disabled' =>
'disable',
130 'starttime' =>
'starttime',
131 'endtime' =>
'endtime'
133 $this->formfield_uname =
'user';
134 $this->formfield_uident =
'pass';
135 $this->formfield_status =
'logintype';
136 $this->sendNoCacheHeaders =
false;
137 $this->getFallBack =
true;
138 $this->getMethodEnabled =
true;
139 $this->lockIP =
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'lockIP'];
140 $this->checkPid =
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'checkFeUserPid'];
141 $this->lifetime = (int)
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'lifetime'];
142 $this->sessionTimeout = (int)
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'sessionTimeout'];
152 $configuredCookieName = trim(
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'cookieName']);
153 if (empty($configuredCookieName)) {
154 $configuredCookieName =
'fe_typo_user';
156 return $configuredCookieName;
166 if ($this->sessionTimeout > 0 && $this->sessionTimeout < $this->lifetime) {
170 $this->sessionDataLifetime = (int)
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'sessionDataLifetime'];
171 if ($this->sessionDataLifetime <= 0) {
172 $this->sessionDataLifetime = 86400;
185 $insertFields = parent::getNewSessionRecord($tempuser);
186 $insertFields[
'ses_permanent'] = $this->is_permanent ? 1 : 0;
187 return $insertFields;
198 return ($this->newSessionID || $this->forceSetCookie)
199 && ((int)$this->lifetime === 0 || !isset($this->user[
'ses_permanent']) || !$this->user[
'ses_permanent']);
210 return $this->lifetime > 0 && isset($this->user[
'ses_permanent']) && $this->user[
'ses_permanent'];
221 $loginData = parent::getLoginFormData();
222 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'permalogin'] == 0 ||
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'permalogin'] == 1) {
223 if ($this->getMethodEnabled) {
224 $isPermanent = GeneralUtility::_GP($this->formfield_permanent);
226 $isPermanent = GeneralUtility::_POST($this->formfield_permanent);
228 if (strlen($isPermanent) != 1) {
229 $isPermanent =
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'permalogin'];
230 } elseif (!$isPermanent) {
233 $this->forceSetCookie =
true;
235 $isPermanent = (bool)$isPermanent;
236 } elseif (
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'permalogin'] == 2) {
239 $isPermanent =
false;
241 $loginData[
'permanent'] = $isPermanent;
242 $this->is_permanent = $isPermanent;
259 $this->dontSetCookie =
false;
260 return parent::createUserSession($tempuser);
272 $this->TSdataArray = [];
274 $this->userTSUpdated =
false;
281 $this->TSdataArray[] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'defaultUserTSconfig'];
284 if (is_array($this->user)) {
285 $this->logger->debug(
'Get usergroups for user', [
286 $this->userid_column => $this->user[$this->userid_column],
287 $this->username_column => $this->user[$this->username_column]
290 $this->logger->debug(
'Get usergroups for "anonymous" user');
296 while (is_object($serviceObj = GeneralUtility::makeInstanceService(
'auth', $subType, $serviceChain))) {
297 $serviceChain .=
',' . $serviceObj->getServiceKey();
298 $serviceObj->initAuth($subType, [], $authInfo, $this);
299 $groupData = $serviceObj->getGroups($this->user, $groupDataArr);
307 $this->logger->debug($subType .
' auth services called: ' . $serviceChain);
309 if (empty($groupDataArr)) {
310 $this->logger->debug(
'No usergroups found by services');
312 if (!empty($groupDataArr)) {
313 $this->logger->debug(count($groupDataArr) .
' usergroup records found by services');
321 while (is_object($serviceObj = GeneralUtility::makeInstanceService(
'auth', $subType, $serviceChain))) {
322 $serviceChain .=
',' . $serviceObj->getServiceKey();
323 $serviceObj->initAuth($subType, [], $authInfo, $this);
324 if (!$serviceObj->authGroup($this->user,
$groupData)) {
326 $this->logger->debug($subType .
' auth service did not auth group', [
335 if ($validGroup && (
string)
$groupData[
'uid'] !==
'') {
342 if (!empty($this->groupData) && !empty($this->groupData[
'TSconfig'])) {
344 foreach ($this->groupData[
'TSconfig'] as $TSdata) {
345 $this->TSdataArray[] = $TSdata;
347 $this->TSdataArray[] = $this->user[
'TSconfig'];
349 ksort($this->groupData[
'title']);
350 ksort($this->groupData[
'uid']);
351 ksort($this->groupData[
'pid']);
353 return !empty($this->groupData[
'uid']) ? count($this->groupData[
'uid']) : 0;
364 if (!$this->userTSUpdated) {
367 $userTS = implode(LF .
'[GLOBAL]' . LF, $this->TSdataArray);
368 $parseObj = GeneralUtility::makeInstance(TypoScriptParser::class);
370 $this->userTS = $parseObj->setup;
371 $this->userTSUpdated =
true;
391 if ($this->userData_change) {
395 if ($this->sesData_change && $this->
id) {
396 if (empty($this->sessionData)) {
400 if (empty($this->user[
'uid']) && !$this->loginHidden && $this->
isCookieSet()) {
405 $sessionRecord[
'ses_anonymous'] = 1;
406 $sessionRecord[
'ses_data'] = serialize($this->sessionData);
408 $this->user = array_merge($this->user ?? [], $updatedSession);
414 'ses_data' => serialize($this->sessionData)
417 $this->user = array_merge($this->user ?? [], $updatedSession);
427 if (!empty($this->sessionData)) {
428 $this->sesData_change =
true;
430 $this->sessionData = [];
434 if ((empty($this->user) && !$this->loginHidden) || $this->user[
'ses_anonymous']) {
459 }
catch (SessionNotFoundException $e) {
463 $keepSessionDataOnLogout = GeneralUtility::makeInstance(Features::class)
464 ->isFeatureEnabled(
'security.frontend.keepSessionDataOnLogout');
471 parent::performLogoff();
487 protected function regenerateSessionId(array $existingSessionRecord = [],
bool $anonymous =
false)
489 if (empty($existingSessionRecord)) {
492 $existingSessionRecord[
'ses_anonymous'] = (int)$anonymous;
494 $existingSessionRecord[
'ses_userid'] = 0;
496 parent::regenerateSessionId($existingSessionRecord, $anonymous);
498 $this->dontSetCookie =
false;
510 public function getKey($type, $key)
518 $value = $this->uc[$key];
537 public function setKey($type, $key, $data)
544 if ($this->user[
'uid']) {
545 if ($data ===
null) {
546 unset($this->uc[$key]);
548 $this->uc[$key] = $data;
550 $this->userData_change =
true;
568 $this->sesData_change =
true;
569 if ($data ===
null) {
570 unset($this->sessionData[$key]);
573 parent::setSessionData($key, $data);
593 public function gc()
607 $this->loginHidden =
true;
617 if (!is_array($this->user) || !$this->user[
'uid']
618 || $this->user[
'is_online'] >=
$GLOBALS[
'EXEC_TIME'] - 60) {
621 $dbConnection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable(
'fe_users');
622 $dbConnection->update(
625 [
'uid' => (
int)$this->user[
'uid']]
627 $this->user[
'is_online'] =
$GLOBALS[
'EXEC_TIME'];