Files
coolify/app/Support/RootSetupWindow.php
Andras Bacsai 5d66fb719e fix(registration): time-limit first root account creation
Open root registration for ten minutes after startup, then require a Coolify restart to reopen it. Update installer credential handling and explain the setup window in the registration UI.
2026-10-26 10:49:19 +01:00

32 lines
704 B
PHP

<?php
namespace App\Support;
use App\Models\User;
use Illuminate\Support\Facades\Cache;
/**
* The first registration creates the root user. It is allowed only for a short time after
* Coolify starts, so a bot cannot claim a fresh install. A restart opens the window again.
*/
class RootSetupWindow
{
public const MINUTES = 10;
private const CACHE_KEY = 'root-setup-window';
public static function openIfNoUserExists(): void
{
if (User::query()->exists()) {
return;
}
Cache::put(self::CACHE_KEY, true, now()->addMinutes(self::MINUTES));
}
public static function isOpen(): bool
{
return Cache::has(self::CACHE_KEY);
}
}