mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
[ticket/16655] Add support for custom error message when exceeding attempts
PHPBB3-16655
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
namespace phpbb\auth\provider;
|
||||
|
||||
use phpbb\captcha\factory;
|
||||
use phpbb\captcha\plugins\captcha_abstract;
|
||||
use phpbb\config\config;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\passwords\manager;
|
||||
@@ -151,13 +152,27 @@ class db extends base
|
||||
$attempts = 0;
|
||||
}
|
||||
|
||||
$login_error_attempts = 'LOGIN_ERROR_ATTEMPTS';
|
||||
$show_captcha = ($this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']) ||
|
||||
($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']);
|
||||
if ($show_captcha)
|
||||
{
|
||||
$captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']);
|
||||
|
||||
// Get custom message for login error when exceeding maximum number of attempts
|
||||
if ($captcha instanceof captcha_abstract)
|
||||
{
|
||||
$login_error_attempts = $captcha->get_login_error_attempts();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$row)
|
||||
{
|
||||
if ($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max'])
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ATTEMPTS,
|
||||
'error_msg' => 'LOGIN_ERROR_ATTEMPTS',
|
||||
'error_msg' => $login_error_attempts,
|
||||
'user_row' => array('user_id' => ANONYMOUS),
|
||||
);
|
||||
}
|
||||
@@ -169,21 +184,17 @@ class db extends base
|
||||
);
|
||||
}
|
||||
|
||||
$show_captcha = ($this->config['max_login_attempts'] && $row['user_login_attempts'] >= $this->config['max_login_attempts']) ||
|
||||
($this->config['ip_login_limit_max'] && $attempts >= $this->config['ip_login_limit_max']);
|
||||
|
||||
// If there are too many login attempts, we need to check for a confirm image
|
||||
// Every auth module is able to define what to do by itself...
|
||||
if ($show_captcha)
|
||||
{
|
||||
$captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']);
|
||||
$captcha->init(CONFIRM_LOGIN);
|
||||
$vc_response = $captcha->validate($row);
|
||||
if ($vc_response)
|
||||
{
|
||||
return array(
|
||||
'status' => LOGIN_ERROR_ATTEMPTS,
|
||||
'error_msg' => 'LOGIN_ERROR_ATTEMPTS',
|
||||
'error_msg' => $login_error_attempts,
|
||||
'user_row' => $row,
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user