mirror of
https://github.com/coollabsio/coolify.git
synced 2026-10-28 17:44:36 +08:00
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.
32 lines
704 B
PHP
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);
|
|
}
|
|
}
|