Loheide-eu-mitarbeiterplatt.../vendor/laravel/fortify/src/Fortify.php
Friederich Loheide 9c0f8de791
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
Phase 0: Fundament für Inhaus
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3)
- Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung
- Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü
- Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person
- Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“
- Benutzerverwaltung im Admin, Zugang vorläufig über is_admin
- vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/
- PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung
- VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 20:35:30 +00:00

378 lines
11 KiB
PHP

<?php
namespace Laravel\Fortify;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Crypt;
use Laravel\Fortify\Contracts\ConfirmPasswordViewResponse;
use Laravel\Fortify\Contracts\CreatesNewUsers;
use Laravel\Fortify\Contracts\LoginViewResponse;
use Laravel\Fortify\Contracts\RedirectsIfTwoFactorAuthenticatable;
use Laravel\Fortify\Contracts\RegisterViewResponse;
use Laravel\Fortify\Contracts\RequestPasswordResetLinkViewResponse;
use Laravel\Fortify\Contracts\ResetPasswordViewResponse;
use Laravel\Fortify\Contracts\ResetsUserPasswords;
use Laravel\Fortify\Contracts\TwoFactorChallengeViewResponse;
use Laravel\Fortify\Contracts\UpdatesUserPasswords;
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
use Laravel\Fortify\Contracts\VerifyEmailViewResponse;
use Laravel\Fortify\Http\Responses\SimpleViewResponse;
class Fortify
{
/**
* The callback that is responsible for building the authentication pipeline array, if applicable.
*
* @var callable|null
*/
public static $authenticateThroughCallback;
/**
* The callback that is responsible for validating authentication credentials, if applicable.
*
* @var callable|null
*/
public static $authenticateUsingCallback;
/**
* The callback that is responsible for confirming user passwords.
*
* @var callable|null
*/
public static $confirmPasswordsUsingCallback;
/**
* The callback that is responsible for generating recovery codes.
*
* @var callable|null
*/
public static $recoveryCodeGenerator;
/**
* Indicates if Fortify routes will be registered.
*
* @var bool
*/
public static $registersRoutes = true;
/**
* The encrypter instance that is used to encrypt attributes.
*
* @var \Illuminate\Contracts\Encryption\Encrypter|null
*/
public static $encrypter;
const PASSWORD_UPDATED = 'password-updated';
const PROFILE_INFORMATION_UPDATED = 'profile-information-updated';
const RECOVERY_CODES_GENERATED = 'recovery-codes-generated';
const TWO_FACTOR_AUTHENTICATION_CONFIRMED = 'two-factor-authentication-confirmed';
const TWO_FACTOR_AUTHENTICATION_DISABLED = 'two-factor-authentication-disabled';
const TWO_FACTOR_AUTHENTICATION_ENABLED = 'two-factor-authentication-enabled';
const VERIFICATION_LINK_SENT = 'verification-link-sent';
/**
* Get the username used for authentication.
*
* @return string
*/
public static function username()
{
return config('fortify.username', 'email');
}
/**
* Get the name of the email address request variable / field.
*
* @return string
*/
public static function email()
{
return config('fortify.email', 'email');
}
/**
* Get a completion redirect path for a specific feature.
*
* @param string $redirect
* @return string
*/
public static function redirects(string $redirect, $default = null)
{
return config('fortify.redirects.'.$redirect) ?? $default ?? config('fortify.home');
}
/**
* Register the views for Fortify using conventional names under the given namespace.
*
* @param string $namespace
* @return void
*/
public static function viewNamespace(string $namespace)
{
static::viewPrefix($namespace.'::');
}
/**
* Register the views for Fortify using conventional names under the given prefix.
*
* @param string $prefix
* @return void
*/
public static function viewPrefix(string $prefix)
{
static::loginView($prefix.'login');
static::twoFactorChallengeView($prefix.'two-factor-challenge');
static::registerView($prefix.'register');
static::requestPasswordResetLinkView($prefix.'forgot-password');
static::resetPasswordView($prefix.'reset-password');
static::verifyEmailView($prefix.'verify-email');
static::confirmPasswordView($prefix.'confirm-password');
}
/**
* Specify which view should be used as the login view.
*
* @param callable|string $view
* @return void
*/
public static function loginView($view)
{
app()->singleton(LoginViewResponse::class, function () use ($view) {
return new SimpleViewResponse($view);
});
}
/**
* Specify which view should be used as the two factor authentication challenge view.
*
* @param callable|string $view
* @return void
*/
public static function twoFactorChallengeView($view)
{
app()->singleton(TwoFactorChallengeViewResponse::class, function () use ($view) {
return new SimpleViewResponse($view);
});
}
/**
* Specify which view should be used as the new password view.
*
* @param callable|string $view
* @return void
*/
public static function resetPasswordView($view)
{
app()->singleton(ResetPasswordViewResponse::class, function () use ($view) {
return new SimpleViewResponse($view);
});
}
/**
* Specify which view should be used as the registration view.
*
* @param callable|string $view
* @return void
*/
public static function registerView($view)
{
app()->singleton(RegisterViewResponse::class, function () use ($view) {
return new SimpleViewResponse($view);
});
}
/**
* Specify which view should be used as the email verification prompt.
*
* @param callable|string $view
* @return void
*/
public static function verifyEmailView($view)
{
app()->singleton(VerifyEmailViewResponse::class, function () use ($view) {
return new SimpleViewResponse($view);
});
}
/**
* Specify which view should be used as the password confirmation prompt.
*
* @param callable|string $view
* @return void
*/
public static function confirmPasswordView($view)
{
app()->singleton(ConfirmPasswordViewResponse::class, function () use ($view) {
return new SimpleViewResponse($view);
});
}
/**
* Specify which view should be used as the request password reset link view.
*
* @param callable|string $view
* @return void
*/
public static function requestPasswordResetLinkView($view)
{
app()->singleton(RequestPasswordResetLinkViewResponse::class, function () use ($view) {
return new SimpleViewResponse($view);
});
}
/**
* Register a callback that is responsible for building the authentication pipeline array.
*
* @param callable $callback
* @return void
*/
public static function loginThrough(callable $callback)
{
static::authenticateThrough($callback);
}
/**
* Register a callback that is responsible for building the authentication pipeline array.
*
* @param callable $callback
* @return void
*/
public static function authenticateThrough(callable $callback)
{
static::$authenticateThroughCallback = $callback;
}
/**
* Register a callback that is responsible for validating incoming authentication credentials.
*
* @param callable $callback
* @return void
*/
public static function authenticateUsing(callable $callback)
{
static::$authenticateUsingCallback = $callback;
}
/**
* Register a class / callback that should be used to redirect users for two factor authentication.
*
* @param callable|string $callback
* @return void
*/
public static function redirectUserForTwoFactorAuthenticationUsing($callback)
{
app()->scoped(RedirectsIfTwoFactorAuthenticatable::class, $callback);
}
/**
* Register a callback that is responsible for confirming existing user passwords as valid.
*
* @param callable $callback
* @return void
*/
public static function confirmPasswordsUsing(callable $callback)
{
static::$confirmPasswordsUsingCallback = $callback;
}
/**
* Register a class / callback that should be used to create new users.
*
* @param callable|string $callback
* @return void
*/
public static function createUsersUsing($callback)
{
app()->singleton(CreatesNewUsers::class, $callback);
}
/**
* Register a class / callback that should be used to update user profile information.
*
* @param callable|string $callback
* @return void
*/
public static function updateUserProfileInformationUsing($callback)
{
app()->singleton(UpdatesUserProfileInformation::class, $callback);
}
/**
* Register a class / callback that should be used to update user passwords.
*
* @param callable|string $callback
* @return void
*/
public static function updateUserPasswordsUsing($callback)
{
app()->singleton(UpdatesUserPasswords::class, $callback);
}
/**
* Register a class / callback that should be used to reset user passwords.
*
* @param callable|string $callback
* @return void
*/
public static function resetUserPasswordsUsing($callback)
{
app()->singleton(ResetsUserPasswords::class, $callback);
}
/**
* Register a callback that should be used to generate recovery codes.
*
* @param callable $callback
* @return void
*/
public static function generateRecoveryCodesUsing(callable $callback)
{
static::$recoveryCodeGenerator = $callback;
}
/**
* Determine if Fortify is confirming two factor authentication configurations.
*
* @return bool
*/
public static function confirmsTwoFactorAuthentication()
{
return Features::enabled(Features::twoFactorAuthentication()) &&
Features::optionEnabled(Features::twoFactorAuthentication(), 'confirm');
}
/**
* Set the encrypter instance that will be used to encrypt attributes.
*
* @param \Illuminate\Contracts\Encryption\Encrypter|null $encrypter
* @return static
*/
public static function encryptUsing($encrypter)
{
static::$encrypter = $encrypter;
return new static;
}
/**
* Get the current encrypter being used by the model.
*
* @return \Illuminate\Contracts\Encryption\Encrypter
*/
public static function currentEncrypter()
{
return static::$encrypter ?? Model::$encrypter ?? Crypt::getFacadeRoot();
}
/**
* Configure Fortify to not register its routes.
*
* @return static
*/
public static function ignoreRoutes()
{
static::$registersRoutes = false;
return new static;
}
}