1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

Merge branch '3.3.x'

This commit is contained in:
Marc Alexander
2021-03-09 19:58:19 +01:00
4 changed files with 45 additions and 10 deletions

View File

@@ -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;
@@ -135,13 +136,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),
);
}
@@ -153,21 +168,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,
);
}