mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/security/276] Prevent sending activation emails multiple times per day
SECURITY-276
This commit is contained in:
@@ -290,18 +290,17 @@ class add extends command
|
||||
{
|
||||
case USER_ACTIVATION_SELF:
|
||||
$email_template = 'user_welcome_inactive';
|
||||
$user_actkey = gen_rand_string(mt_rand(6, 10));
|
||||
break;
|
||||
case USER_ACTIVATION_ADMIN:
|
||||
$email_template = 'admin_welcome_inactive';
|
||||
$user_actkey = gen_rand_string(mt_rand(6, 10));
|
||||
break;
|
||||
default:
|
||||
$email_template = 'user_welcome';
|
||||
$user_actkey = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$user_actkey = $this->get_activation_key($user_id);
|
||||
|
||||
if (!class_exists('messenger'))
|
||||
{
|
||||
require($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
|
||||
@@ -321,6 +320,35 @@ class add extends command
|
||||
$messenger->send(NOTIFY_EMAIL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user activation key
|
||||
*
|
||||
* @param int $user_id User ID
|
||||
*
|
||||
* @return string User activation key for user
|
||||
*/
|
||||
protected function get_activation_key(int $user_id): string
|
||||
{
|
||||
$user_actkey = '';
|
||||
|
||||
if ($this->config['require_activation'] == USER_ACTIVATION_SELF || $this->config['require_activation'] == USER_ACTIVATION_ADMIN)
|
||||
{
|
||||
$user_actkey = gen_rand_string(mt_rand(6, 10));
|
||||
|
||||
$sql_ary = [
|
||||
'user_actkey' => $user_actkey,
|
||||
'user_actkey_expiration' => strtotime('+1 day'),
|
||||
];
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE user_id = ' . $user_id;
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
return $user_actkey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to translate questions to the user
|
||||
*
|
||||
|
Reference in New Issue
Block a user