Problem: Failed logins always try log in against legacy upstream

Solution: Make the login fallback optional and deactivate it in the default config.

I'm leaving the code in here mostly because I want to revisit it and make it modular so I can later on plug my own FreeIPA things :)
This commit is contained in:
Lucas Bickel 2017-02-20 23:12:25 +01:00
parent 4557395a86
commit 10532dc4e8
2 changed files with 27 additions and 15 deletions

View file

@ -45,7 +45,7 @@ class LoginController extends Zend_Controller_Action
//uses separate layout without a navigation.
$this->_helper->layout->setLayout('login');
$error = false;
$this->view->error = false;
$baseUrl = Application_Common_OsPath::getBaseDir();
@ -92,7 +92,7 @@ class LoginController extends Zend_Controller_Action
Application_Model_Preference::SetUserLocale($locale);
$this->_redirect('showbuilder');
} else {
} elseif (LIBRETIME_ENABLE_WHMCS) {
$email = $form->getValue('username');
$authAdapter = new WHMCS_Auth_Adapter("admin", $email, $password);
$auth = Zend_Auth::getInstance();
@ -105,23 +105,14 @@ class LoginController extends Zend_Controller_Action
$this->_redirect('showbuilder');
}
else {
$message = _("Wrong username or password provided. Please try again.");
Application_Model_Subjects::increaseLoginAttempts($username);
Application_Model_LoginAttempts::increaseAttempts($_SERVER['REMOTE_ADDR']);
$form = new Application_Form_Login();
$error = true;
//Only show the captcha if you get your login wrong 4 times in a row.
if (Application_Model_Subjects::getLoginAttempts($username) > 3)
{
$form->addRecaptcha();
}
$form = $this->loginError($username);
}
} else {
$form = $this->loginError($username);
}
}
}
$this->view->message = $message;
$this->view->error = $error;
$this->view->form = $form;
$this->view->airtimeVersion = Application_Model_Preference::GetAirtimeVersion();
$this->view->airtimeCopyright = AIRTIME_COPYRIGHT_DATE;
@ -260,4 +251,24 @@ class LoginController extends Zend_Controller_Action
$this->view->form = $form;
}
/**
* populates view with results from a login error and adds a new form
*
* @param String $username user that failed to login
* @return new form
*/
private function loginError($username)
{
$this->view->message = _("Wrong username or password provided. Please try again.");
Application_Model_Subjects::increaseLoginAttempts($username);
Application_Model_LoginAttempts::increaseAttempts($_SERVER['REMOTE_ADDR']);
$form = new Application_Form_Login();
$this->view->error = true;
//Only show the captcha if you get your login wrong 4 times in a row.
if (Application_Model_Subjects::getLoginAttempts($username) > 3) {
$form->addRecaptcha();
}
return $form;
}
}