/** * Form to ask the users to authenticate with auth code * @param string $messageNoAccess * @return string * @throws \Exception */ public function authcode($messageNoAccess = null) { $rememberMe = Common::getRequestVar('form_rememberme', '0', 'string') == '1'; $form = $this->getAuthCodeForm(); if ($form->getSubmitValue('form_authcode') && $form->validate()) { $nonce = $form->getSubmitValue('form_nonce'); if (Nonce::verifyNonce('Login.login', $nonce)) { $this->auth->setAuthCode($form->getSubmitValue('form_authcode')); if ($this->auth->validateAuthCode()) { try { $rememberMe = Common::getRequestVar('form_rememberme', '0', 'string') == '1'; $this->authenticateAndRedirect($this->auth->getLogin(), null, $rememberMe); } catch (\Exception $e) { } } Nonce::discardNonce('Login.login'); $form->getElements()[0]->setError(Piwik::translate('GoogleAuthenticator_AuthCodeInvalid')); } else { $messageNoAccess = $this->getMessageExceptionNoAccess(); } } return $this->renderAuthCode($this->auth->getLogin(), Piwik::translate('Login_LogIn'), $rememberMe, $messageNoAccess); }