TYPO3 CMS  TYPO3_6-2
AjaxLoginHandler.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend;
3 
22 
34  public function login(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj) {
35  if ($this->isAuthorizedBackendSession()) {
36  $json = array('success' => TRUE);
37  if ($this->hasLoginBeenProcessed()) {
39  $formProtection->setSessionTokenFromRegistry();
40  $formProtection->persistSessionToken();
41  }
42  } else {
43  $json = array('success' => FALSE);
44  }
45  $ajaxObj->addContent('login', $json);
46  $ajaxObj->setContentFormat('json');
47  }
48 
54  protected function isAuthorizedBackendSession() {
55  return isset($GLOBALS['BE_USER']) && $GLOBALS['BE_USER'] instanceof \TYPO3\CMS\Core\Authentication\BackendUserAuthentication && isset($GLOBALS['BE_USER']->user['uid']);
56  }
57 
63  protected function hasLoginBeenProcessed() {
64  $loginFormData = $GLOBALS['BE_USER']->getLoginFormData();
65  return $loginFormData['status'] === 'login' && !empty($loginFormData['uname']) && !empty($loginFormData['uident']);
66  }
67 
75  public function logout(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj) {
76  $GLOBALS['BE_USER']->logoff();
77  if (isset($GLOBALS['BE_USER']->user['uid'])) {
78  $ajaxObj->addContent('logout', array('success' => FALSE));
79  } else {
80  $ajaxObj->addContent('logout', array('success' => TRUE));
81  }
82  $ajaxObj->setContentFormat('json');
83  }
84 
92  public function refreshLogin(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj) {
93  $GLOBALS['BE_USER']->checkAuthentication();
94  $ajaxObj->addContent('refresh', array('success' => TRUE));
95  $ajaxObj->setContentFormat('json');
96  }
97 
106  public function isTimedOut(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj) {
107  if (is_object($GLOBALS['BE_USER'])) {
108  $ajaxObj->setContentFormat('json');
109  if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
110  $ajaxObj->addContent('login', array('will_time_out' => FALSE, 'locked' => TRUE));
111  $ajaxObj->setContentFormat('json');
112  } elseif (!isset($GLOBALS['BE_USER']->user['uid'])) {
113  $ajaxObj->addContent('login', array('timed_out' => TRUE));
114  } else {
115  $GLOBALS['BE_USER']->fetchUserSession(TRUE);
116  $ses_tstamp = $GLOBALS['BE_USER']->user['ses_tstamp'];
117  $timeout = $GLOBALS['BE_USER']->auth_timeout_field;
118  // If 120 seconds from now is later than the session timeout, we need to show the refresh dialog.
119  // 120 is somewhat arbitrary to allow for a little room during the countdown and load times, etc.
120  if ($GLOBALS['EXEC_TIME'] >= $ses_tstamp + $timeout - 120) {
121  $ajaxObj->addContent('login', array('will_time_out' => TRUE));
122  } else {
123  $ajaxObj->addContent('login', array('will_time_out' => FALSE));
124  }
125  }
126  } else {
127  $ajaxObj->addContent('login', array('success' => FALSE, 'error' => 'No BE_USER object'));
128  }
129  }
130 
138  public function getChallenge(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $parent) {
139  session_start();
140  $_SESSION['login_challenge'] = md5(uniqid('', TRUE) . getmypid());
141  session_commit();
142  $parent->addContent('challenge', $_SESSION['login_challenge']);
143  $parent->setContentFormat('json');
144  }
145 
146 }
getChallenge(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $parent)
$parameters
Definition: FileDumpEID.php:15
logout(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
isTimedOut(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
refreshLogin(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
login(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
if($ajaxRegistryEntry !==NULL) $ajaxObj
Definition: ajax.php:63