Fix silly CAPTCHA flow, now only asks if you get your password wrong 4
times in a row
This commit is contained in:
parent
2cc7557cb7
commit
f157cad877
1 changed files with 38 additions and 36 deletions
|
@ -52,48 +52,50 @@ class LoginController extends Zend_Controller_Action
|
||||||
$username = $form->getValue('username');
|
$username = $form->getValue('username');
|
||||||
$password = $form->getValue('password');
|
$password = $form->getValue('password');
|
||||||
$locale = $form->getValue('locale');
|
$locale = $form->getValue('locale');
|
||||||
if (Application_Model_Subjects::getLoginAttempts($username) >= 3 && $form->getElement('captcha') == NULL) {
|
|
||||||
$form->addRecaptcha();
|
|
||||||
} else {
|
|
||||||
$authAdapter = Application_Model_Auth::getAuthAdapter();
|
|
||||||
|
|
||||||
//pass to the adapter the submitted username and password
|
$authAdapter = Application_Model_Auth::getAuthAdapter();
|
||||||
$authAdapter->setIdentity($username)
|
|
||||||
->setCredential($password);
|
//pass to the adapter the submitted username and password
|
||||||
|
$authAdapter->setIdentity($username)
|
||||||
|
->setCredential($password);
|
||||||
|
|
||||||
|
$result = $auth->authenticate($authAdapter);
|
||||||
|
if ($result->isValid()) {
|
||||||
|
//all info about this user from the login table omit only the password
|
||||||
|
$userInfo = $authAdapter->getResultRowObject(null, 'password');
|
||||||
|
|
||||||
|
//the default storage is a session with namespace Zend_Auth
|
||||||
|
$authStorage = $auth->getStorage();
|
||||||
|
$authStorage->write($userInfo);
|
||||||
|
|
||||||
|
Application_Model_LoginAttempts::resetAttempts($_SERVER['REMOTE_ADDR']);
|
||||||
|
Application_Model_Subjects::resetLoginAttempts($username);
|
||||||
|
|
||||||
|
//set the user locale in case user changed it in when logging in
|
||||||
|
Application_Model_Preference::SetUserLocale($locale);
|
||||||
|
|
||||||
|
$this->_redirect('Showbuilder');
|
||||||
|
} else {
|
||||||
|
$email = $form->getValue('username');
|
||||||
|
$authAdapter = new WHMCS_Auth_Adapter("admin", $email, $password);
|
||||||
|
$auth = Zend_Auth::getInstance();
|
||||||
$result = $auth->authenticate($authAdapter);
|
$result = $auth->authenticate($authAdapter);
|
||||||
if ($result->isValid()) {
|
if ($result->isValid()) {
|
||||||
//all info about this user from the login table omit only the password
|
|
||||||
$userInfo = $authAdapter->getResultRowObject(null, 'password');
|
|
||||||
|
|
||||||
//the default storage is a session with namespace Zend_Auth
|
|
||||||
$authStorage = $auth->getStorage();
|
|
||||||
$authStorage->write($userInfo);
|
|
||||||
|
|
||||||
Application_Model_LoginAttempts::resetAttempts($_SERVER['REMOTE_ADDR']);
|
|
||||||
Application_Model_Subjects::resetLoginAttempts($username);
|
|
||||||
|
|
||||||
//set the user locale in case user changed it in when logging in
|
//set the user locale in case user changed it in when logging in
|
||||||
Application_Model_Preference::SetUserLocale($locale);
|
Application_Model_Preference::SetUserLocale($locale);
|
||||||
|
|
||||||
$this->_redirect('Showbuilder');
|
$this->_redirect('Showbuilder');
|
||||||
} else {
|
}
|
||||||
$email = $form->getValue('username');
|
else {
|
||||||
$authAdapter = new WHMCS_Auth_Adapter("admin", $email, $password);
|
$message = _("Wrong username or password provided. Please try again.");
|
||||||
$auth = Zend_Auth::getInstance();
|
Application_Model_Subjects::increaseLoginAttempts($username);
|
||||||
$result = $auth->authenticate($authAdapter);
|
Application_Model_LoginAttempts::increaseAttempts($_SERVER['REMOTE_ADDR']);
|
||||||
if ($result->isValid()) {
|
$form = new Application_Form_Login();
|
||||||
//set the user locale in case user changed it in when logging in
|
$error = true;
|
||||||
Application_Model_Preference::SetUserLocale($locale);
|
//Only show the captcha if you get your login wrong 4 times in a row.
|
||||||
|
if (Application_Model_Subjects::getLoginAttempts($username) > 3)
|
||||||
$this->_redirect('Showbuilder');
|
{
|
||||||
}
|
$form->addRecaptcha();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue