mivita/app/Rules/PersonName.php
Kevin Adametz 4c944aa15d Spamschutz Kontakt + Registrierung: Turnstile, Rate-Limit, Honeypot; Passwort min. 8
- Kontaktformular: keine Mail mehr an die eingegebene Adresse (wurde als
  Spam-Versender missbraucht); Anfrage nur an Kontakt-Adresse + Berater (BCC),
  Reply-To = Absender; Eingaben in der Mail escaped
- Kontakt + Registrierung: Cloudflare Turnstile statt reCAPTCHA (Schluessel
  aus dem Code in die .env), Rate-Limits, Honeypot + Mindest-Ausfuellzeit,
  Namensregel (lateinische Schrift, max. 50 Zeichen), Form Requests
- Registrierung: Partner-Nummer nur fuer aktive Berater (vorher ungeprueft)
- CRM: POST /register abgeschaltet (legte ohne Captcha Benutzer an)
- Passwort-Mindestlaenge systemweit 8 Zeichen ueber Password::defaults()
- Log abgefangener Anfragen: storage/logs/form-spam-*.log
- Doku und Protokoll: dev/2026-10-09-spam/README.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 08:22:02 +00:00

29 lines
921 B
PHP

<?php
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Translation\PotentiallyTranslatedString;
/**
* Vor- oder Nachname: nur lateinische Schrift (inkl. Umlaute/Akzente), Leerzeichen, Bindestrich,
* Apostroph und Punkt, max. 50 Zeichen. Hält Werbetexte und Links aus Namensfeldern fern,
* die sonst in Begrüßungen von Mails landen.
*/
class PersonName implements ValidationRule
{
public const PATTERN = "/^[\p{Latin}\p{M}][\p{Latin}\p{M} '.\-]*$/u";
public const MAX_LENGTH = 50;
/**
* @param Closure(string, ?string=): PotentiallyTranslatedString $fail
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (! is_string($value) || mb_strlen($value) > self::MAX_LENGTH || ! preg_match(self::PATTERN, $value)) {
$fail(__('form_protection.name_invalid'));
}
}
}