Issue 14381: Fix automated register policy on first install

This commit is contained in:
Michael 2024-08-24 12:48:20 +00:00
parent a3a8b6c9ec
commit 24209c4374

View file

@ -435,13 +435,14 @@ class Register extends BaseModule
}
public static function getPolicy(): int
{
$admins = User::getAdminList(['login_date']);
$days = DI::config()->get('system', 'admin_inactivity_limit');
if ($days == 0) {
if ($days == 0 || empty($admins)) {
return intval(DI::config()->get('config', 'register_policy'));
}
$inactive_since = DateTimeFormat::utc('now - ' . $days . ' day');
foreach (User::getAdminList(['login_date']) as $admin) {
foreach ($admins as $admin) {
if (strtotime($admin['login_date']) > strtotime($inactive_since)) {
return intval(DI::config()->get('config', 'register_policy'));
}