2 namespace TYPO3\CMS\Frontend\Authentication;
119 parent::__construct();
123 $this->dontSetCookie =
true;
125 $this->session_table =
'fe_sessions';
126 $this->name = self::getCookieName();
127 $this->get_name =
'ftu';
128 $this->loginType =
'FE';
129 $this->user_table =
'fe_users';
130 $this->username_column =
'username';
131 $this->userident_column =
'password';
132 $this->userid_column =
'uid';
133 $this->lastLogin_column =
'lastlogin';
134 $this->enablecolumns = array(
135 'deleted' =>
'deleted',
136 'disabled' =>
'disable',
137 'starttime' =>
'starttime',
138 'endtime' =>
'endtime'
140 $this->formfield_uname =
'user';
141 $this->formfield_uident =
'pass';
142 $this->formfield_status =
'logintype';
143 $this->auth_timeout_field = 6000;
144 $this->sendNoCacheHeaders =
false;
145 $this->getFallBack =
true;
146 $this->getMethodEnabled =
true;
156 $configuredCookieName = trim(
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'cookieName']);
157 if (empty($configuredCookieName)) {
158 $configuredCookieName =
'fe_typo_user';
160 return $configuredCookieName;
171 if ((
int)$this->auth_timeout_field > 0 && (
int)$this->auth_timeout_field < $this->lifetime) {
175 $this->sessionDataLifetime = (int)
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'sessionDataLifetime'];
176 if ($this->sessionDataLifetime <= 0) {
177 $this->sessionDataLifetime = 86400;
190 $insertFields = parent::getNewSessionRecord($tempuser);
192 return $insertFields;
203 return ($this->newSessionID || $this->forceSetCookie)
204 && ($this->lifetime == 0 || !isset($this->user[
'ses_permanent']) || !$this->user[
'ses_permanent']);
215 return $this->lifetime > 0 && isset($this->user[
'ses_permanent']) && $this->user[
'ses_permanent'];
226 $loginData = parent::getLoginFormData();
227 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'permalogin'] == 0 ||
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'permalogin'] == 1) {
228 if ($this->getMethodEnabled) {
233 if (strlen($isPermanent) != 1) {
234 $isPermanent =
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'permalogin'];
235 }
elseif (!$isPermanent) {
238 $this->forceSetCookie =
true;
240 $isPermanent = $isPermanent ? 1 : 0;
246 $loginData[
'permanent'] = $isPermanent;
247 $this->is_permanent = $isPermanent;
264 $this->dontSetCookie =
false;
265 return parent::createUserSession($tempuser);
277 $this->TSdataArray = array();
278 $this->userTS = array();
279 $this->userTSUpdated =
false;
280 $this->groupData = array(
286 $this->TSdataArray[] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'defaultUserTSconfig'];
289 if ($this->writeDevLog) {
290 if (is_array($this->user)) {
296 $groupDataArr = array();
301 $serviceChain .=
',' . $serviceObj->getServiceKey();
302 $serviceObj->initAuth($subType, array(), $authInfo, $this);
303 $groupData = $serviceObj->getGroups($this->user, $groupDataArr);
310 if ($this->writeDevLog && $serviceChain) {
313 if ($this->writeDevLog && empty($groupDataArr)) {
316 if ($this->writeDevLog && !empty($groupDataArr)) {
326 $serviceChain .=
',' . $serviceObj->getServiceKey();
327 $serviceObj->initAuth($subType, array(), $authInfo, $this);
328 if (!$serviceObj->authGroup($this->user, $groupData)) {
330 if ($this->writeDevLog) {
339 $this->groupData[
'title'][$groupData[
'uid']] = $groupData[
'title'];
340 $this->groupData[
'uid'][$groupData[
'uid']] = $groupData[
'uid'];
341 $this->groupData[
'pid'][$groupData[
'uid']] = $groupData[
'pid'];
342 $this->groupData[
'TSconfig'][$groupData[
'uid']] = $groupData[
'TSconfig'];
345 if (!empty($this->groupData) && !empty($this->groupData[
'TSconfig'])) {
347 foreach ($this->groupData[
'TSconfig'] as $TSdata) {
348 $this->TSdataArray[] = $TSdata;
350 $this->TSdataArray[] = $this->user[
'TSconfig'];
352 ksort($this->groupData[
'title']);
353 ksort($this->groupData[
'uid']);
354 ksort($this->groupData[
'pid']);
356 return !empty($this->groupData[
'uid']) ? count($this->groupData[
'uid']) : 0;
367 if (!$this->userTSUpdated) {
370 $userTS = implode(LF .
'[GLOBAL]' . LF, $this->TSdataArray);
373 $this->userTS = $parseObj->setup;
374 $this->userTSUpdated =
true;
396 if ($this->
id && empty($this->sesData)) {
397 $statement = $this->db->prepare_SELECTquery(
'*',
'fe_session_data',
'hash = :hash');
398 $statement->execute(array(
':hash' => $this->
id));
399 if (($sesDataRow = $statement->fetch()) !==
false) {
400 $this->sesData = unserialize($sesDataRow[
'content']);
401 $this->sessionDataTimestamp = $sesDataRow[
'tstamp'];
419 if ($this->userData_change) {
422 if ($this->sesData_change && $this->
id) {
423 if (empty($this->sesData)) {
427 if (empty($this->user[
'uid']) && !$this->loginHidden && $this->
isCookieSet()) {
430 }
elseif ($this->sessionDataTimestamp === null) {
432 $insertFields = array(
434 'content' => serialize($this->sesData),
437 $this->sessionDataTimestamp =
$GLOBALS[
'EXEC_TIME'];
438 $this->db->exec_INSERTquery(
'fe_session_data', $insertFields);
443 $updateFields = array(
444 'content' => serialize($this->sesData),
447 $this->sessionDataTimestamp =
$GLOBALS[
'EXEC_TIME'];
448 $this->db->exec_UPDATEquery(
'fe_session_data',
'hash=' . $this->db->fullQuoteStr($this->id,
'fe_session_data'), $updateFields);
460 $this->sessionDataTimestamp = null;
461 $this->db->exec_DELETEquery(
'fe_session_data',
'hash=' . $this->db->fullQuoteStr($this->id,
'fe_session_data'));
488 parent::regenerateSessionId();
490 $this->db->exec_UPDATEquery(
492 'hash=' . $this->db->fullQuoteStr($oldSessionId,
'fe_session_data'),
493 array(
'hash' => $this->
id)
497 $this->dontSetCookie =
false;
508 $timeoutTimeStamp = (int)(
$GLOBALS[
'EXEC_TIME'] - $this->sessionDataLifetime);
509 $this->db->exec_DELETEquery(
'fe_session_data',
'tstamp < ' . $timeoutTimeStamp);
530 $value = $this->uc[$key];
533 $value = $this->sesData[$key];
551 public function setKey($type, $key, $data)
558 if ($this->user[
'uid']) {
559 if ($data === null) {
560 unset($this->uc[$key]);
562 $this->uc[$key] = $data;
564 $this->userData_change =
true;
568 if ($data === null) {
569 unset($this->sesData[$key]);
571 $this->sesData[$key] = $data;
573 $this->sesData_change =
true;
587 return $this->
getKey(
'ses', $key);
599 $this->
setKey(
'ses', $key, $data);
617 if (!$maxSizeOfSessionData || $this->
isCookieSet()) {
618 if ($recs[
'clear_all']) {
619 $this->
setKey(
'ses',
'recs', array());
622 $recs_array = $this->
getKey(
'ses',
'recs');
623 foreach ($recs as $table => $data) {
624 if (is_array($data)) {
625 foreach ($data as $rec_id => $value) {
626 if ($value != $recs_array[$table][$rec_id]) {
627 $recs_array[$table][$rec_id] = $value;
633 if ($change && (!$maxSizeOfSessionData || strlen(serialize($recs_array)) < $maxSizeOfSessionData)) {
634 $this->
setKey(
'ses',
'recs', $recs_array);
651 $count = parent::isExistingSessionRecord(
$id);
653 if ($count ==
false) {
654 $statement = $this->db->prepare_SELECTquery(
'content,tstamp',
'fe_session_data',
'hash = :hash');
655 $res = $statement->execute(array(
':hash' =>
$id));
656 if ($res !==
false) {
657 if ($sesDataRow = $statement->fetch()) {
659 $this->sesData = unserialize($sesDataRow[
'content']);
660 $this->sessionDataTimestamp = $sesDataRow[
'tstamp'];
679 $this->loginHidden =
true;