mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge branch '3.3.x'
This commit is contained in:
@@ -296,18 +296,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);
|
||||
@@ -327,6 +326,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' => \phpbb\user::get_token_expiration(),
|
||||
];
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE user_id = ' . (int) $user_id;
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
return $user_actkey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to translate questions to the user
|
||||
*
|
||||
|
@@ -85,9 +85,8 @@ class cron_runner_listener implements EventSubscriberInterface
|
||||
{
|
||||
$task->run();
|
||||
}
|
||||
|
||||
$this->cron_lock->release();
|
||||
}
|
||||
$this->cron_lock->release();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v33x;
|
||||
|
||||
use phpbb\db\migration\migration;
|
||||
|
||||
class add_resend_activation_expiration extends migration
|
||||
{
|
||||
public static function depends_on(): array
|
||||
{
|
||||
return [
|
||||
'\phpbb\db\migration\data\v33x\v3311',
|
||||
];
|
||||
}
|
||||
|
||||
public function update_schema(): array
|
||||
{
|
||||
return [
|
||||
'add_columns' => [
|
||||
$this->table_prefix . 'users' => [
|
||||
'user_actkey_expiration' => ['TIMESTAMP', 0, 'after' => 'user_actkey'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function revert_schema(): array
|
||||
{
|
||||
return [
|
||||
'drop_columns' => [
|
||||
$this->table_prefix . 'users' => [
|
||||
'user_actkey_expiration',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
38
phpBB/phpbb/db/migration/data/v33x/v3312.php
Normal file
38
phpBB/phpbb/db/migration/data/v33x/v3312.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v33x;
|
||||
|
||||
class v3312 extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.3.12', '>=');
|
||||
}
|
||||
|
||||
public static function depends_on()
|
||||
{
|
||||
return [
|
||||
'\phpbb\db\migration\data\v33x\add_resend_activation_expiration',
|
||||
'\phpbb\db\migration\data\v33x\add_user_last_active',
|
||||
'\phpbb\db\migration\data\v33x\v3312rc1',
|
||||
];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['config.update', ['version', '3.3.12']],
|
||||
];
|
||||
}
|
||||
}
|
@@ -242,7 +242,7 @@ class reset_password
|
||||
|
||||
$sql_ary = [
|
||||
'reset_token' => $reset_token,
|
||||
'reset_token_expiration' => strtotime('+1 day'),
|
||||
'reset_token_expiration' => $this->user::get_token_expiration(),
|
||||
];
|
||||
|
||||
$sql = 'UPDATE ' . $this->users_table . '
|
||||
|
@@ -59,7 +59,7 @@ class user extends \phpbb\session
|
||||
* @param \phpbb\language\language $lang phpBB's Language loader
|
||||
* @param string $datetime_class Class name of datetime class
|
||||
*/
|
||||
function __construct(\phpbb\language\language $lang, $datetime_class)
|
||||
public function __construct(\phpbb\language\language $lang, $datetime_class)
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
@@ -80,6 +80,16 @@ class user extends \phpbb\session
|
||||
return $this->is_setup_flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get expiration time for user tokens, e.g. activation or reset password tokens
|
||||
*
|
||||
* @return int Expiration for user tokens
|
||||
*/
|
||||
public static function get_token_expiration(): int
|
||||
{
|
||||
return strtotime('+1 day') ?: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter for BC compatibility
|
||||
*
|
||||
|
Reference in New Issue
Block a user