/** * Pretty the same as in login action of Login plugin * - Adds the handling for required auth code for login * * @param string $messageNoAccess Access error message * @param bool $infoMessage * @internal param string $currentUrl Current URL * @return string */ public function login($messageNoAccess = null, $infoMessage = false) { if ($this->auth->isAuthCodeRequired()) { return $this->authcode(); } if (!Piwik::isUserIsAnonymous()) { $urlToRedirect = Url::getCurrentUrlWithoutQueryString(); Url::redirectToUrl($urlToRedirect); } $form = new \Piwik\Plugins\Login\FormLogin(); $form->removeAttribute('action'); // remove action attribute, otherwise hash part will be lost if ($form->validate()) { $nonce = $form->getSubmitValue('form_nonce'); if (Nonce::verifyNonce('Login.login', $nonce)) { $login = $form->getSubmitValue('form_login'); $password = $form->getSubmitValue('form_password'); $rememberMe = $form->getSubmitValue('form_rememberme') == '1'; try { $this->authenticateAndRedirect($login, $password, $rememberMe); } catch (AuthCodeRequiredException $e) { return $this->authcode(); } catch (\Exception $e) { $messageNoAccess = $e->getMessage(); } } else { $messageNoAccess = $this->getMessageExceptionNoAccess(); } } $view = new View('@Login/login'); $view->AccessErrorString = $messageNoAccess; $view->infoMessage = nl2br($infoMessage); $view->addForm($form); $this->configureView($view); self::setHostValidationVariablesView($view); return $view->render(); }