*/ class LoginController { const SIGNAL_RenderLoginForm = 'renderLoginForm'; // Internal, GPvars: // GPvar: redirect_url; The URL to redirect to after login. /** * @todo Define visibility */ public $redirect_url; // GPvar: Defines which interface to load (from interface selector) /** * @todo Define visibility */ public $GPinterface; // GPvar: preset username /** * @todo Define visibility */ public $u; // GPvar: preset password /** * @todo Define visibility */ public $p; // GPvar: If "L" is "OUT", then any logged in used is logged out. If redirect_url is given, we redirect to it /** * @todo Define visibility */ public $L; // Login-refresh boolean; The backend will call this script with this value set when the login is close to being expired and the form needs to be redrawn. /** * @todo Define visibility */ public $loginRefresh; // Value of forms submit button for login. /** * @todo Define visibility */ public $commandLI; // Internal, static: // Set to the redirect URL of the form (may be redirect_url or "backend.php") /** * @todo Define visibility */ public $redirectToURL; // Internal, dynamic: // Content accumulation /** * @todo Define visibility */ public $content; // A selector box for selecting value for "interface" may be rendered into this variable /** * @todo Define visibility */ public $interfaceSelector; // A selector box for selecting value for "interface" may be rendered into this variable // this will have an onchange action which will redirect the user to the selected interface right away /** * @todo Define visibility */ public $interfaceSelector_jump; // A hidden field, if the interface is not set. /** * @todo Define visibility */ public $interfaceSelector_hidden; // Additional hidden fields to be placed at the login form /** * @todo Define visibility */ public $addFields_hidden = ''; // sets the level of security. *'normal' = clear-text. 'challenged' = hashed // password/username from form in $formfield_uident. 'superchallenged' = hashed password hashed again with username. /** * @todo Define visibility */ public $loginSecurityLevel = 'superchallenged'; /** * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher */ protected $signalSlotDispatcher; /** * Initialize the login box. Will also react on a &L=OUT flag and exit. * * @return void * @todo Define visibility */ public function init() { // We need a PHP session session for most login levels session_start(); $this->redirect_url = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('redirect_url')); $this->GPinterface = GeneralUtility::_GP('interface'); // Grabbing preset username and password, for security reasons this feature only works if SSL is used if (GeneralUtility::getIndpEnv('TYPO3_SSL')) { $this->u = GeneralUtility::_GP('u'); $this->p = GeneralUtility::_GP('p'); } // If "L" is "OUT", then any logged in is logged out. If redirect_url is given, we redirect to it $this->L = GeneralUtility::_GP('L'); // Login $this->loginRefresh = GeneralUtility::_GP('loginRefresh'); // Value of "Login" button. If set, the login button was pressed. $this->commandLI = GeneralUtility::_GP('commandLI'); // Sets the level of security from conf vars if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) { $this->loginSecurityLevel = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']; } // Try to get the preferred browser language $preferredBrowserLanguage = $GLOBALS['LANG']->csConvObj->getPreferredClientLanguage(GeneralUtility::getIndpEnv('HTTP_ACCEPT_LANGUAGE')); // If we found a $preferredBrowserLanguage and it is not the default language and no be_user is logged in // initialize $GLOBALS['LANG'] again with $preferredBrowserLanguage if ($preferredBrowserLanguage != 'default' && !$GLOBALS['BE_USER']->user['uid']) { $GLOBALS['LANG']->init($preferredBrowserLanguage); } $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_login.xlf'); // Setting the redirect URL to "backend.php" if no alternative input is given $this->redirectToURL = $this->redirect_url ? $this->redirect_url : 'backend.php'; // Do a logout if the command is set if ($this->L == 'OUT' && is_object($GLOBALS['BE_USER'])) { $GLOBALS['BE_USER']->logoff(); if ($this->redirect_url) { HttpUtility::redirect($this->redirect_url); } die; } } /** * Main function - creating the login/logout form * * @return void * @todo Define visibility */ public function main() { // Initialize template object: $GLOBALS['TBE_TEMPLATE']->bodyTagAdditions = ' onload="startUp();"'; $GLOBALS['TBE_TEMPLATE']->moduleTemplate = $GLOBALS['TBE_TEMPLATE']->getHtmlTemplate('EXT:backend/Resources/Private/Templates/login.html'); $GLOBALS['TBE_TEMPLATE']->getPageRenderer()->loadExtJS(); $GLOBALS['TBE_TEMPLATE']->getPageRenderer()->loadPrototype(); $GLOBALS['TBE_TEMPLATE']->getPageRenderer()->loadScriptaculous(); // Set JavaScript for creating a MD5 hash of the password: $GLOBALS['TBE_TEMPLATE']->JScode .= $this->getJScode(); // Checking, if we should make a redirect. // Might set JavaScript in the header to close window. $this->checkRedirect(); // Initialize interface selectors: $this->makeInterfaceSelectorBox(); // Creating form based on whether there is a login or not: if (!$GLOBALS['BE_USER']->user['uid']) { $GLOBALS['TBE_TEMPLATE']->form = $this->startForm(); $loginForm = $this->makeLoginForm(); } else { $GLOBALS['TBE_TEMPLATE']->form = '