Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m16s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m17s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m17s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 1m21s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 1m19s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 1m14s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 1m12s
CI / Build-Artefakte aktuell (pull_request) Successful in 52s
- Nach der Einrichtung Erfolgsmeldung auf der Anmeldeseite (per Parameter, da die Sitzung beim Wechsel auf den Datenbank-Speicher verloren geht) - Root-.htaccess für Hoster ohne einstellbaren Webroot: leitet intern nach public/, .env und Programmdateien bleiben unerreichbar - Begrüßungskarte: Namen nicht mehr abschneiden; Personenzahl mit korrekter Einzahl - docs/INSTALLATION.md für Kunden: Voraussetzungen, Einrichtung, Cron, Updates - CI: vendor-Vergleich ohne composer/installed.php (enthält den Projekt-Commit) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
67 lines
2.5 KiB
PHP
67 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Actions\Fortify\ResetUserPassword;
|
|
use App\Actions\Fortify\UpdateUserPassword;
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Events\Login;
|
|
use Illuminate\Cache\RateLimiting\Limit;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\RateLimiter;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Support\Str;
|
|
use Inertia\Inertia;
|
|
use Laravel\Fortify\Fortify;
|
|
|
|
class FortifyServiceProvider extends ServiceProvider
|
|
{
|
|
public function boot(): void
|
|
{
|
|
Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
|
|
Fortify::resetUserPasswordsUsing(ResetUserPassword::class);
|
|
|
|
Fortify::loginView(fn (Request $request) => Inertia::render('Auth/Login', [
|
|
'canResetPassword' => true,
|
|
'status' => $request->boolean('eingerichtet')
|
|
? 'Die Einrichtung ist abgeschlossen. Sie können sich jetzt mit Ihrem Administratorkonto anmelden.'
|
|
: $request->session()->get('status'),
|
|
]));
|
|
|
|
Fortify::requestPasswordResetLinkView(fn (Request $request) => Inertia::render('Auth/ForgotPassword', [
|
|
'status' => $request->session()->get('status'),
|
|
]));
|
|
|
|
Fortify::resetPasswordView(fn (Request $request) => Inertia::render('Auth/ResetPassword', [
|
|
'email' => $request->input('email'),
|
|
'token' => $request->route('token'),
|
|
]));
|
|
|
|
// Deaktivierte Konten und Konten ohne lokales Passwort (später: nur IdP) können
|
|
// sich nicht per Passwort anmelden.
|
|
Fortify::authenticateUsing(function (Request $request): ?User {
|
|
$user = User::query()->where('email', Str::lower($request->input(Fortify::username())))->first();
|
|
|
|
if ($user && $user->is_active && $user->password !== null
|
|
&& Hash::check($request->input('password'), $user->password)) {
|
|
return $user;
|
|
}
|
|
|
|
return null;
|
|
});
|
|
|
|
Event::listen(Login::class, function (Login $event): void {
|
|
if ($event->user instanceof User) {
|
|
$event->user->forceFill(['last_login_at' => now()])->saveQuietly();
|
|
}
|
|
});
|
|
|
|
RateLimiter::for('login', function (Request $request) {
|
|
$throttleKey = Str::transliterate(Str::lower($request->input(Fortify::username())).'|'.$request->ip());
|
|
|
|
return Limit::perMinute(5)->by($throttleKey);
|
|
});
|
|
}
|
|
}
|