Make the magic-link resend cooldown configurable
EmailVerifier::RESEND_INTERVAL_SECONDS was a hardcoded class constant shared (via a copy-of-a-constant) by AuthController and EmailVerificationController. It's now a constructor param (resendIntervalSeconds, default 60, same as before) sourced from Config -- new MAGIC_LINK_RESEND_SECONDS env var, default unchanged. Docker Compose sets it to 0, so magic links resend immediately during local development instead of waiting out the throttle. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,8 @@ final class Config
|
||||
public readonly string $webauthnRpId,
|
||||
/** WebAuthn relying party display name, shown by the browser/OS passkey prompt. */
|
||||
public readonly string $webauthnRpName,
|
||||
/** Minimum gap between magic links sent to the same address. */
|
||||
public readonly int $resendIntervalSeconds,
|
||||
public readonly MailConfig $mail,
|
||||
) {
|
||||
}
|
||||
@@ -56,6 +58,8 @@ final class Config
|
||||
$webauthnRpId = self::env('WEBAUTHN_RP_ID') ?? (parse_url($appUrl, PHP_URL_HOST) ?: 'localhost');
|
||||
$webauthnRpName = self::env('WEBAUTHN_RP_NAME', 'Projects');
|
||||
|
||||
$resendIntervalSeconds = (int) (self::env('MAGIC_LINK_RESEND_SECONDS') ?? '60');
|
||||
|
||||
$mailLogPath = self::env('MAIL_LOG_PATH', $storagePath . '/mail.log');
|
||||
if (!self::isAbsolutePath($mailLogPath)) {
|
||||
$mailLogPath = $basePath . '/' . ltrim($mailLogPath, '/');
|
||||
@@ -82,6 +86,7 @@ final class Config
|
||||
$appUrl,
|
||||
$webauthnRpId,
|
||||
$webauthnRpName,
|
||||
$resendIntervalSeconds,
|
||||
$mail,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user