File manager - Edit - /var/www/payraty/helpdesk/public/storage/branding_media/images/fortify.tar
Back
database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php 0000755 00000002346 00000000000 0023030 0 ustar 00 <?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Laravel\Fortify\Fortify; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::table('users', function (Blueprint $table) { $table->text('two_factor_secret') ->after('password') ->nullable(); $table->text('two_factor_recovery_codes') ->after('two_factor_secret') ->nullable(); if (Fortify::confirmsTwoFactorAuthentication()) { $table->timestamp('two_factor_confirmed_at') ->after('two_factor_recovery_codes') ->nullable(); } }); } /** * Reverse the migrations. */ public function down(): void { Schema::table('users', function (Blueprint $table) { $table->dropColumn(array_merge([ 'two_factor_secret', 'two_factor_recovery_codes', ], Fortify::confirmsTwoFactorAuthentication() ? [ 'two_factor_confirmed_at', ] : [])); }); } }; testbench.yaml 0000755 00000000133 00000000000 0007350 0 ustar 00 providers: - Laravel\Fortify\FortifyServiceProvider migrations: - database/migrations config/fortify.php 0000755 00000003306 00000000000 0010152 0 ustar 00 <?php use Laravel\Fortify\Features; return [ 'guard' => 'web', 'middleware' => ['web'], 'auth_middleware' => 'auth', 'passwords' => 'users', 'username' => 'email', 'email' => 'email', 'views' => true, 'home' => '/home', 'prefix' => '', 'domain' => null, 'lowercase_usernames' => false, 'limiters' => [ 'login' => null, ], 'paths' => [ 'login' => null, 'logout' => null, 'password' => [ 'request' => null, 'reset' => null, 'email' => null, 'update' => null, 'confirm' => null, 'confirmation' => null, ], 'register' => null, 'verification' => [ 'notice' => null, 'verify' => null, 'send' => null, ], 'user-profile-information' => [ 'update' => null, ], 'user-password' => [ 'update' => null, ], 'two-factor' => [ 'login' => null, 'enable' => null, 'confirm' => null, 'disable' => null, 'qr-code' => null, 'secret-key' => null, 'recovery-codes' => null, ], ], 'redirects' => [ 'login' => null, 'logout' => null, 'password-confirmation' => null, 'register' => null, 'email-verification' => null, 'password-reset' => null, ], 'features' => [ Features::registration(), Features::resetPasswords(), Features::emailVerification(), Features::updateProfileInformation(), Features::updatePasswords(), Features::twoFactorAuthentication(), ], ]; LICENSE.md 0000755 00000002063 00000000000 0006115 0 ustar 00 The MIT License (MIT) Copyright (c) Taylor Otwell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. workbench/database/factories/UserFactory.php 0000755 00000000616 00000000000 0015177 0 ustar 00 <?php namespace Database\Factories; use App\Models\User; /** * @template TModel of \App\Models\User * * @extends \Illuminate\Database\Eloquent\Factories\Factory<TModel> */ class UserFactory extends \Orchestra\Testbench\Factories\UserFactory { /** * The name of the factory's corresponding model. * * @var class-string<TModel> */ protected $model = User::class; } workbench/app/Models/User.php 0000755 00000001261 00000000000 0012124 0 ustar 00 <?php namespace App\Models; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { /** * The attributes that are mass assignable. * * @var array<int, string> */ protected $fillable = [ 'name', 'email', 'password', ]; /** * The attributes that should be hidden for serialization. * * @var array<int, string> */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array<string, string> */ protected $casts = [ 'email_verified_at' => 'datetime', ]; } README.md 0000755 00000003271 00000000000 0005772 0 ustar 00 <p align="center"><img src="/art/logo.svg" alt="Logo Laravel Fortify"></p> <p align="center"> <a href="https://github.com/laravel/fortify/actions"> <img src="https://github.com/laravel/fortify/workflows/tests/badge.svg" alt="Build Status"> </a> <a href="https://packagist.org/packages/laravel/fortify"> <img src="https://img.shields.io/packagist/dt/laravel/fortify" alt="Total Downloads"> </a> <a href="https://packagist.org/packages/laravel/fortify"> <img src="https://img.shields.io/packagist/v/laravel/fortify" alt="Latest Stable Version"> </a> <a href="https://packagist.org/packages/laravel/fortify"> <img src="https://img.shields.io/packagist/l/laravel/fortify" alt="License"> </a> </p> ## Introduction Laravel Fortify is a frontend agnostic authentication backend for Laravel. Fortify powers the registration, authentication, and two-factor authentication features of [Laravel Jetstream](https://github.com/laravel/jetstream). ## Official Documentation Documentation for Fortify can be found on the [Laravel website](https://laravel.com/docs/fortify). ## Contributing Thank you for considering contributing to Fortify! You can read the contribution guide [here](.github/CONTRIBUTING.md). ## Code of Conduct In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). ## Security Vulnerabilities Please review [our security policy](https://github.com/laravel/fortify/security/policy) on how to report security vulnerabilities. ## License Laravel Fortify is open-sourced software licensed under the [MIT license](LICENSE.md). routes/routes.php 0000755 00000021503 00000000000 0010064 0 ustar 00 <?php use Illuminate\Support\Facades\Route; use Laravel\Fortify\Features; use Laravel\Fortify\Http\Controllers\AuthenticatedSessionController; use Laravel\Fortify\Http\Controllers\ConfirmablePasswordController; use Laravel\Fortify\Http\Controllers\ConfirmedPasswordStatusController; use Laravel\Fortify\Http\Controllers\ConfirmedTwoFactorAuthenticationController; use Laravel\Fortify\Http\Controllers\EmailVerificationNotificationController; use Laravel\Fortify\Http\Controllers\EmailVerificationPromptController; use Laravel\Fortify\Http\Controllers\NewPasswordController; use Laravel\Fortify\Http\Controllers\PasswordController; use Laravel\Fortify\Http\Controllers\PasswordResetLinkController; use Laravel\Fortify\Http\Controllers\ProfileInformationController; use Laravel\Fortify\Http\Controllers\RecoveryCodeController; use Laravel\Fortify\Http\Controllers\RegisteredUserController; use Laravel\Fortify\Http\Controllers\TwoFactorAuthenticatedSessionController; use Laravel\Fortify\Http\Controllers\TwoFactorAuthenticationController; use Laravel\Fortify\Http\Controllers\TwoFactorQrCodeController; use Laravel\Fortify\Http\Controllers\TwoFactorSecretKeyController; use Laravel\Fortify\Http\Controllers\VerifyEmailController; use Laravel\Fortify\RoutePath; Route::group(['middleware' => config('fortify.middleware', ['web'])], function () { $enableViews = config('fortify.views', true); // Authentication... if ($enableViews) { Route::get(RoutePath::for('login', '/login'), [AuthenticatedSessionController::class, 'create']) ->middleware(['guest:'.config('fortify.guard')]) ->name('login'); } $limiter = config('fortify.limiters.login'); $twoFactorLimiter = config('fortify.limiters.two-factor'); $verificationLimiter = config('fortify.limiters.verification', '6,1'); Route::post(RoutePath::for('login', '/login'), [AuthenticatedSessionController::class, 'store']) ->middleware(array_filter([ 'guest:'.config('fortify.guard'), $limiter ? 'throttle:'.$limiter : null, ])); Route::post(RoutePath::for('logout', '/logout'), [AuthenticatedSessionController::class, 'destroy']) ->name('logout'); // Password Reset... if (Features::enabled(Features::resetPasswords())) { if ($enableViews) { Route::get(RoutePath::for('password.request', '/forgot-password'), [PasswordResetLinkController::class, 'create']) ->middleware(['guest:'.config('fortify.guard')]) ->name('password.request'); Route::get(RoutePath::for('password.reset', '/reset-password/{token}'), [NewPasswordController::class, 'create']) ->middleware(['guest:'.config('fortify.guard')]) ->name('password.reset'); } Route::post(RoutePath::for('password.email', '/forgot-password'), [PasswordResetLinkController::class, 'store']) ->middleware(['guest:'.config('fortify.guard')]) ->name('password.email'); Route::post(RoutePath::for('password.update', '/reset-password'), [NewPasswordController::class, 'store']) ->middleware(['guest:'.config('fortify.guard')]) ->name('password.update'); } // Registration... if (Features::enabled(Features::registration())) { if ($enableViews) { Route::get(RoutePath::for('register', '/register'), [RegisteredUserController::class, 'create']) ->middleware(['guest:'.config('fortify.guard')]) ->name('register'); } Route::post(RoutePath::for('register', '/register'), [RegisteredUserController::class, 'store']) ->middleware(['guest:'.config('fortify.guard')]); } // Email Verification... if (Features::enabled(Features::emailVerification())) { if ($enableViews) { Route::get(RoutePath::for('verification.notice', '/email/verify'), [EmailVerificationPromptController::class, '__invoke']) ->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]) ->name('verification.notice'); } Route::get(RoutePath::for('verification.verify', '/email/verify/{id}/{hash}'), [VerifyEmailController::class, '__invoke']) ->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard'), 'signed', 'throttle:'.$verificationLimiter]) ->name('verification.verify'); Route::post(RoutePath::for('verification.send', '/email/verification-notification'), [EmailVerificationNotificationController::class, 'store']) ->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard'), 'throttle:'.$verificationLimiter]) ->name('verification.send'); } // Profile Information... if (Features::enabled(Features::updateProfileInformation())) { Route::put(RoutePath::for('user-profile-information.update', '/user/profile-information'), [ProfileInformationController::class, 'update']) ->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]) ->name('user-profile-information.update'); } // Passwords... if (Features::enabled(Features::updatePasswords())) { Route::put(RoutePath::for('user-password.update', '/user/password'), [PasswordController::class, 'update']) ->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]) ->name('user-password.update'); } // Password Confirmation... if ($enableViews) { Route::get(RoutePath::for('password.confirm', '/user/confirm-password'), [ConfirmablePasswordController::class, 'show']) ->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]); } Route::get(RoutePath::for('password.confirmation', '/user/confirmed-password-status'), [ConfirmedPasswordStatusController::class, 'show']) ->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]) ->name('password.confirmation'); Route::post(RoutePath::for('password.confirm', '/user/confirm-password'), [ConfirmablePasswordController::class, 'store']) ->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]) ->name('password.confirm'); // Two Factor Authentication... if (Features::enabled(Features::twoFactorAuthentication())) { if ($enableViews) { Route::get(RoutePath::for('two-factor.login', '/two-factor-challenge'), [TwoFactorAuthenticatedSessionController::class, 'create']) ->middleware(['guest:'.config('fortify.guard')]) ->name('two-factor.login'); } Route::post(RoutePath::for('two-factor.login', '/two-factor-challenge'), [TwoFactorAuthenticatedSessionController::class, 'store']) ->middleware(array_filter([ 'guest:'.config('fortify.guard'), $twoFactorLimiter ? 'throttle:'.$twoFactorLimiter : null, ])); $twoFactorMiddleware = Features::optionEnabled(Features::twoFactorAuthentication(), 'confirmPassword') ? [config('fortify.auth_middleware', 'auth').':'.config('fortify.guard'), 'password.confirm'] : [config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]; Route::post(RoutePath::for('two-factor.enable', '/user/two-factor-authentication'), [TwoFactorAuthenticationController::class, 'store']) ->middleware($twoFactorMiddleware) ->name('two-factor.enable'); Route::post(RoutePath::for('two-factor.confirm', '/user/confirmed-two-factor-authentication'), [ConfirmedTwoFactorAuthenticationController::class, 'store']) ->middleware($twoFactorMiddleware) ->name('two-factor.confirm'); Route::delete(RoutePath::for('two-factor.disable', '/user/two-factor-authentication'), [TwoFactorAuthenticationController::class, 'destroy']) ->middleware($twoFactorMiddleware) ->name('two-factor.disable'); Route::get(RoutePath::for('two-factor.qr-code', '/user/two-factor-qr-code'), [TwoFactorQrCodeController::class, 'show']) ->middleware($twoFactorMiddleware) ->name('two-factor.qr-code'); Route::get(RoutePath::for('two-factor.secret-key', '/user/two-factor-secret-key'), [TwoFactorSecretKeyController::class, 'show']) ->middleware($twoFactorMiddleware) ->name('two-factor.secret-key'); Route::get(RoutePath::for('two-factor.recovery-codes', '/user/two-factor-recovery-codes'), [RecoveryCodeController::class, 'index']) ->middleware($twoFactorMiddleware) ->name('two-factor.recovery-codes'); Route::post(RoutePath::for('two-factor.recovery-codes', '/user/two-factor-recovery-codes'), [RecoveryCodeController::class, 'store']) ->middleware($twoFactorMiddleware); } }); src/Console/InstallCommand.php 0000755 00000002477 00000000000 0012331 0 ustar 00 <?php namespace Laravel\Fortify\Console; use Illuminate\Console\Command; use Illuminate\Support\ServiceProvider; use Laravel\Fortify\FortifyServiceProvider; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'fortify:install')] class InstallCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'fortify:install'; /** * The console command description. * * @var string */ protected $description = 'Install all of the Fortify resources'; /** * Execute the console command. * * @return void */ public function handle() { $this->callSilent('vendor:publish', [ '--provider' => FortifyServiceProvider::class, ]); $this->registerFortifyServiceProvider(); $this->components->info('Fortify scaffolding installed successfully.'); } /** * Register the Fortify service provider in the application configuration file. */ protected function registerFortifyServiceProvider(): void { if (! method_exists(ServiceProvider::class, 'addProviderToBootstrapFile')) { return; } ServiceProvider::addProviderToBootstrapFile(\App\Providers\FortifyServiceProvider::class); } } src/RoutePath.php 0000755 00000000551 00000000000 0007724 0 ustar 00 <?php namespace Laravel\Fortify; class RoutePath { /** * Get the route path for the given route name. * * @param string $routeName * @param string $default * @return string */ public static function for(string $routeName, string $default) { return config('fortify.paths.'.$routeName) ?? $default; } } src/TwoFactorAuthenticatable.php 0000755 00000004504 00000000000 0012741 0 ustar 00 <?php namespace Laravel\Fortify; use BaconQrCode\Renderer\Color\Rgb; use BaconQrCode\Renderer\Image\SvgImageBackEnd; use BaconQrCode\Renderer\ImageRenderer; use BaconQrCode\Renderer\RendererStyle\Fill; use BaconQrCode\Renderer\RendererStyle\RendererStyle; use BaconQrCode\Writer; use Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider; trait TwoFactorAuthenticatable { /** * Determine if two-factor authentication has been enabled. * * @return bool */ public function hasEnabledTwoFactorAuthentication() { if (Fortify::confirmsTwoFactorAuthentication()) { return ! is_null($this->two_factor_secret) && ! is_null($this->two_factor_confirmed_at); } return ! is_null($this->two_factor_secret); } /** * Get the user's two factor authentication recovery codes. * * @return array */ public function recoveryCodes() { return json_decode(decrypt($this->two_factor_recovery_codes), true); } /** * Replace the given recovery code with a new one in the user's stored codes. * * @param string $code * @return void */ public function replaceRecoveryCode($code) { $this->forceFill([ 'two_factor_recovery_codes' => encrypt(str_replace( $code, RecoveryCode::generate(), decrypt($this->two_factor_recovery_codes) )), ])->save(); } /** * Get the QR code SVG of the user's two factor authentication QR code URL. * * @return string */ public function twoFactorQrCodeSvg() { $svg = (new Writer( new ImageRenderer( new RendererStyle(192, 0, null, null, Fill::uniformColor(new Rgb(255, 255, 255), new Rgb(45, 55, 72))), new SvgImageBackEnd ) ))->writeString($this->twoFactorQrCodeUrl()); return trim(substr($svg, strpos($svg, "\n") + 1)); } /** * Get the two factor authentication QR code URL. * * @return string */ public function twoFactorQrCodeUrl() { return app(TwoFactorAuthenticationProvider::class)->qrCodeUrl( config('app.name'), $this->{Fortify::username()}, decrypt($this->two_factor_secret) ); } } src/Http/Responses/VerifyEmailResponse.php 0000755 00000001245 00000000000 0014645 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\VerifyEmailResponse as VerifyEmailResponseContract; use Laravel\Fortify\Fortify; class VerifyEmailResponse implements VerifyEmailResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 204) : redirect()->intended(Fortify::redirects('email-verification').'?verified=1'); } } src/Http/Responses/ProfileInformationUpdatedResponse.php 0000755 00000001335 00000000000 0017546 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\ProfileInformationUpdatedResponse as ProfileInformationUpdatedResponseContract; use Laravel\Fortify\Fortify; class ProfileInformationUpdatedResponse implements ProfileInformationUpdatedResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 200) : back()->with('status', Fortify::PROFILE_INFORMATION_UPDATED); } } src/Http/Responses/PasswordConfirmedResponse.php 0000755 00000001302 00000000000 0016054 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\PasswordConfirmedResponse as PasswordConfirmedResponseContract; use Laravel\Fortify\Fortify; class PasswordConfirmedResponse implements PasswordConfirmedResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 201) : redirect()->intended(Fortify::redirects('password-confirmation')); } } src/Http/Responses/TwoFactorConfirmedResponse.php 0000755 00000001311 00000000000 0016162 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\TwoFactorConfirmedResponse as TwoFactorConfirmedResponseContract; use Laravel\Fortify\Fortify; class TwoFactorConfirmedResponse implements TwoFactorConfirmedResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 200) : back()->with('status', Fortify::TWO_FACTOR_AUTHENTICATION_CONFIRMED); } } src/Http/Responses/RecoveryCodesGeneratedResponse.php 0000755 00000001316 00000000000 0017023 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\RecoveryCodesGeneratedResponse as RecoveryCodesGeneratedResponseContract; use Laravel\Fortify\Fortify; class RecoveryCodesGeneratedResponse implements RecoveryCodesGeneratedResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 200) : back()->with('status', Fortify::RECOVERY_CODES_GENERATED); } } src/Http/Responses/FailedPasswordResetResponse.php 0000755 00000002173 00000000000 0016344 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Validation\ValidationException; use Laravel\Fortify\Contracts\FailedPasswordResetResponse as FailedPasswordResetResponseContract; class FailedPasswordResetResponse implements FailedPasswordResetResponseContract { /** * The response status language key. * * @var string */ protected $status; /** * Create a new response instance. * * @param string $status * @return void */ public function __construct(string $status) { $this->status = $status; } /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { if ($request->wantsJson()) { throw ValidationException::withMessages([ 'email' => [trans($this->status)], ]); } return back() ->withInput($request->only('email')) ->withErrors(['email' => trans($this->status)]); } } src/Http/Responses/TwoFactorLoginResponse.php 0000755 00000001246 00000000000 0015333 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\TwoFactorLoginResponse as TwoFactorLoginResponseContract; use Laravel\Fortify\Fortify; class TwoFactorLoginResponse implements TwoFactorLoginResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 204) : redirect()->intended(Fortify::redirects('login')); } } src/Http/Responses/EmailVerificationNotificationSentResponse.php 0000755 00000001370 00000000000 0021223 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\EmailVerificationNotificationSentResponse as EmailVerificationNotificationSentResponseContract; use Laravel\Fortify\Fortify; class EmailVerificationNotificationSentResponse implements EmailVerificationNotificationSentResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 202) : back()->with('status', Fortify::VERIFICATION_LINK_SENT); } } src/Http/Responses/LogoutResponse.php 0000755 00000001200 00000000000 0013671 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\LogoutResponse as LogoutResponseContract; use Laravel\Fortify\Fortify; class LogoutResponse implements LogoutResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 204) : redirect(Fortify::redirects('logout', '/')); } } src/Http/Responses/TwoFactorDisabledResponse.php 0000755 00000001273 00000000000 0015772 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\TwoFactorLoginResponse as TwoFactorLoginResponseContract; use Laravel\Fortify\Fortify; class TwoFactorDisabledResponse implements TwoFactorLoginResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 200) : back()->with('status', Fortify::TWO_FACTOR_AUTHENTICATION_DISABLED); } } src/Http/Responses/PasswordResetResponse.php 0000755 00000002127 00000000000 0015236 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\PasswordResetResponse as PasswordResetResponseContract; use Laravel\Fortify\Fortify; class PasswordResetResponse implements PasswordResetResponseContract { /** * The response status language key. * * @var string */ protected $status; /** * Create a new response instance. * * @param string $status * @return void */ public function __construct(string $status) { $this->status = $status; } /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse(['message' => trans($this->status)], 200) : redirect(Fortify::redirects('password-reset', config('fortify.views', true) ? route('login') : null))->with('status', trans($this->status)); } } src/Http/Responses/PasswordUpdateResponse.php 0000755 00000001226 00000000000 0015375 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\PasswordUpdateResponse as PasswordUpdateResponseContract; use Laravel\Fortify\Fortify; class PasswordUpdateResponse implements PasswordUpdateResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 200) : back()->with('status', Fortify::PASSWORD_UPDATED); } } src/Http/Responses/TwoFactorEnabledResponse.php 0000755 00000001271 00000000000 0015613 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\TwoFactorLoginResponse as TwoFactorLoginResponseContract; use Laravel\Fortify\Fortify; class TwoFactorEnabledResponse implements TwoFactorLoginResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 200) : back()->with('status', Fortify::TWO_FACTOR_AUTHENTICATION_ENABLED); } } src/Http/Responses/SimpleViewResponse.php 0000755 00000003225 00000000000 0014515 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Contracts\Support\Responsable; use Laravel\Fortify\Contracts\ConfirmPasswordViewResponse; use Laravel\Fortify\Contracts\LoginViewResponse; use Laravel\Fortify\Contracts\RegisterViewResponse; use Laravel\Fortify\Contracts\RequestPasswordResetLinkViewResponse; use Laravel\Fortify\Contracts\ResetPasswordViewResponse; use Laravel\Fortify\Contracts\TwoFactorChallengeViewResponse; use Laravel\Fortify\Contracts\VerifyEmailViewResponse; class SimpleViewResponse implements LoginViewResponse, ResetPasswordViewResponse, RegisterViewResponse, RequestPasswordResetLinkViewResponse, TwoFactorChallengeViewResponse, VerifyEmailViewResponse, ConfirmPasswordViewResponse { /** * The name of the view or the callable used to generate the view. * * @var callable|string */ protected $view; /** * Create a new response instance. * * @param callable|string $view * @return void */ public function __construct($view) { $this->view = $view; } /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { if (! is_callable($this->view) || is_string($this->view)) { return view($this->view, ['request' => $request]); } $response = call_user_func($this->view, $request); if ($response instanceof Responsable) { return $response->toResponse($request); } return $response; } } src/Http/Responses/SuccessfulPasswordResetLinkRequestResponse.php 0000755 00000002057 00000000000 0021467 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\SuccessfulPasswordResetLinkRequestResponse as SuccessfulPasswordResetLinkRequestResponseContract; class SuccessfulPasswordResetLinkRequestResponse implements SuccessfulPasswordResetLinkRequestResponseContract { /** * The response status language key. * * @var string */ protected $status; /** * Create a new response instance. * * @param string $status * @return void */ public function __construct(string $status) { $this->status = $status; } /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse(['message' => trans($this->status)], 200) : back()->with('status', trans($this->status)); } } src/Http/Responses/FailedTwoFactorLoginResponse.php 0000755 00000001760 00000000000 0016441 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Validation\ValidationException; use Laravel\Fortify\Contracts\FailedTwoFactorLoginResponse as FailedTwoFactorLoginResponseContract; class FailedTwoFactorLoginResponse implements FailedTwoFactorLoginResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { [$key, $message] = $request->filled('recovery_code') ? ['recovery_code', __('The provided two factor recovery code was invalid.')] : ['code', __('The provided two factor authentication code was invalid.')]; if ($request->wantsJson()) { throw ValidationException::withMessages([ $key => [$message], ]); } return redirect()->route('two-factor.login')->withErrors([$key => $message]); } } src/Http/Responses/FailedPasswordResetLinkRequestResponse.php 0000755 00000002247 00000000000 0020535 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Validation\ValidationException; use Laravel\Fortify\Contracts\FailedPasswordResetLinkRequestResponse as FailedPasswordResetLinkRequestResponseContract; class FailedPasswordResetLinkRequestResponse implements FailedPasswordResetLinkRequestResponseContract { /** * The response status language key. * * @var string */ protected $status; /** * Create a new response instance. * * @param string $status * @return void */ public function __construct(string $status) { $this->status = $status; } /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { if ($request->wantsJson()) { throw ValidationException::withMessages([ 'email' => [trans($this->status)], ]); } return back() ->withInput($request->only('email')) ->withErrors(['email' => trans($this->status)]); } } src/Http/Responses/RegisterResponse.php 0000755 00000001221 00000000000 0014207 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\JsonResponse; use Laravel\Fortify\Contracts\RegisterResponse as RegisterResponseContract; use Laravel\Fortify\Fortify; class RegisterResponse implements RegisterResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? new JsonResponse('', 201) : redirect()->intended(Fortify::redirects('register')); } } src/Http/Responses/FailedPasswordConfirmationResponse.php 0000755 00000001505 00000000000 0017710 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Validation\ValidationException; use Laravel\Fortify\Contracts\FailedPasswordConfirmationResponse as FailedPasswordConfirmationResponseContract; class FailedPasswordConfirmationResponse implements FailedPasswordConfirmationResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { $message = __('The provided password was incorrect.'); if ($request->wantsJson()) { throw ValidationException::withMessages([ 'password' => [$message], ]); } return back()->withErrors(['password' => $message]); } } src/Http/Responses/LockoutResponse.php 0000755 00000002562 00000000000 0014054 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Illuminate\Http\Response; use Illuminate\Validation\ValidationException; use Laravel\Fortify\Contracts\LockoutResponse as LockoutResponseContract; use Laravel\Fortify\Fortify; use Laravel\Fortify\LoginRateLimiter; class LockoutResponse implements LockoutResponseContract { /** * The login rate limiter instance. * * @var \Laravel\Fortify\LoginRateLimiter */ protected $limiter; /** * Create a new response instance. * * @param \Laravel\Fortify\LoginRateLimiter $limiter * @return void */ public function __construct(LoginRateLimiter $limiter) { $this->limiter = $limiter; } /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return with($this->limiter->availableIn($request), function ($seconds) { throw ValidationException::withMessages([ Fortify::username() => [ trans('auth.throttle', [ 'seconds' => $seconds, 'minutes' => ceil($seconds / 60), ]), ], ])->status(Response::HTTP_TOO_MANY_REQUESTS); }); } } src/Http/Responses/LoginResponse.php 0000755 00000001160 00000000000 0013475 0 ustar 00 <?php namespace Laravel\Fortify\Http\Responses; use Laravel\Fortify\Contracts\LoginResponse as LoginResponseContract; use Laravel\Fortify\Fortify; class LoginResponse implements LoginResponseContract { /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { return $request->wantsJson() ? response()->json(['two_factor' => false]) : redirect()->intended(Fortify::redirects('login')); } } src/Http/Controllers/ProfileInformationController.php 0000755 00000002065 00000000000 0017112 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Illuminate\Support\Str; use Laravel\Fortify\Contracts\ProfileInformationUpdatedResponse; use Laravel\Fortify\Contracts\UpdatesUserProfileInformation; use Laravel\Fortify\Fortify; class ProfileInformationController extends Controller { /** * Update the user's profile information. * * @param \Illuminate\Http\Request $request * @param \Laravel\Fortify\Contracts\UpdatesUserProfileInformation $updater * @return \Laravel\Fortify\Contracts\ProfileInformationUpdatedResponse */ public function update(Request $request, UpdatesUserProfileInformation $updater) { if (config('fortify.lowercase_usernames')) { $request->merge([ Fortify::username() => Str::lower($request->{Fortify::username()}), ]); } $updater->update($request->user(), $request->all()); return app(ProfileInformationUpdatedResponse::class); } } src/Http/Controllers/PasswordController.php 0000755 00000001513 00000000000 0015103 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Laravel\Fortify\Contracts\PasswordUpdateResponse; use Laravel\Fortify\Contracts\UpdatesUserPasswords; use Laravel\Fortify\Events\PasswordUpdatedViaController; class PasswordController extends Controller { /** * Update the user's password. * * @param \Illuminate\Http\Request $request * @param \Laravel\Fortify\Contracts\UpdatesUserPasswords $updater * @return \Laravel\Fortify\Contracts\PasswordUpdateResponse */ public function update(Request $request, UpdatesUserPasswords $updater) { $updater->update($request->user(), $request->all()); event(new PasswordUpdatedViaController($request->user())); return app(PasswordUpdateResponse::class); } } src/Http/Controllers/ConfirmedTwoFactorAuthenticationController.php 0000755 00000001436 00000000000 0021744 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Laravel\Fortify\Actions\ConfirmTwoFactorAuthentication; use Laravel\Fortify\Contracts\TwoFactorConfirmedResponse; class ConfirmedTwoFactorAuthenticationController extends Controller { /** * Enable two factor authentication for the user. * * @param \Illuminate\Http\Request $request * @param \Laravel\Fortify\Actions\ConfirmTwoFactorAuthentication $confirm * @return \Laravel\Fortify\Contracts\TwoFactorConfirmedResponse */ public function store(Request $request, ConfirmTwoFactorAuthentication $confirm) { $confirm($request->user(), $request->input('code')); return app(TwoFactorConfirmedResponse::class); } } src/Http/Controllers/VerifyEmailController.php 0000755 00000001527 00000000000 0015522 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Auth\Events\Verified; use Illuminate\Routing\Controller; use Laravel\Fortify\Contracts\VerifyEmailResponse; use Laravel\Fortify\Http\Requests\VerifyEmailRequest; class VerifyEmailController extends Controller { /** * Mark the authenticated user's email address as verified. * * @param \Laravel\Fortify\Http\Requests\VerifyEmailRequest $request * @return \Laravel\Fortify\Contracts\VerifyEmailResponse */ public function __invoke(VerifyEmailRequest $request) { if ($request->user()->hasVerifiedEmail()) { return app(VerifyEmailResponse::class); } if ($request->user()->markEmailAsVerified()) { event(new Verified($request->user())); } return app(VerifyEmailResponse::class); } } src/Http/Controllers/EmailVerificationPromptController.php 0000755 00000001300 00000000000 0020067 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Laravel\Fortify\Contracts\VerifyEmailViewResponse; use Laravel\Fortify\Fortify; class EmailVerificationPromptController extends Controller { /** * Display the email verification prompt. * * @param \Illuminate\Http\Request $request * @return \Laravel\Fortify\Contracts\VerifyEmailViewResponse */ public function __invoke(Request $request) { return $request->user()->hasVerifiedEmail() ? redirect()->intended(Fortify::redirects('email-verification')) : app(VerifyEmailViewResponse::class); } } src/Http/Controllers/AuthenticatedSessionController.php 0000755 00000006575 00000000000 0017444 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Illuminate\Routing\Pipeline; use Laravel\Fortify\Actions\AttemptToAuthenticate; use Laravel\Fortify\Actions\CanonicalizeUsername; use Laravel\Fortify\Actions\EnsureLoginIsNotThrottled; use Laravel\Fortify\Actions\PrepareAuthenticatedSession; use Laravel\Fortify\Actions\RedirectIfTwoFactorAuthenticatable; use Laravel\Fortify\Contracts\LoginResponse; use Laravel\Fortify\Contracts\LoginViewResponse; use Laravel\Fortify\Contracts\LogoutResponse; use Laravel\Fortify\Features; use Laravel\Fortify\Fortify; use Laravel\Fortify\Http\Requests\LoginRequest; class AuthenticatedSessionController extends Controller { /** * The guard implementation. * * @var \Illuminate\Contracts\Auth\StatefulGuard */ protected $guard; /** * Create a new controller instance. * * @param \Illuminate\Contracts\Auth\StatefulGuard $guard * @return void */ public function __construct(StatefulGuard $guard) { $this->guard = $guard; } /** * Show the login view. * * @param \Illuminate\Http\Request $request * @return \Laravel\Fortify\Contracts\LoginViewResponse */ public function create(Request $request): LoginViewResponse { return app(LoginViewResponse::class); } /** * Attempt to authenticate a new session. * * @param \Laravel\Fortify\Http\Requests\LoginRequest $request * @return mixed */ public function store(LoginRequest $request) { return $this->loginPipeline($request)->then(function ($request) { return app(LoginResponse::class); }); } /** * Get the authentication pipeline instance. * * @param \Laravel\Fortify\Http\Requests\LoginRequest $request * @return \Illuminate\Pipeline\Pipeline */ protected function loginPipeline(LoginRequest $request) { if (Fortify::$authenticateThroughCallback) { return (new Pipeline(app()))->send($request)->through(array_filter( call_user_func(Fortify::$authenticateThroughCallback, $request) )); } if (is_array(config('fortify.pipelines.login'))) { return (new Pipeline(app()))->send($request)->through(array_filter( config('fortify.pipelines.login') )); } return (new Pipeline(app()))->send($request)->through(array_filter([ config('fortify.limiters.login') ? null : EnsureLoginIsNotThrottled::class, config('fortify.lowercase_usernames') ? CanonicalizeUsername::class : null, Features::enabled(Features::twoFactorAuthentication()) ? RedirectIfTwoFactorAuthenticatable::class : null, AttemptToAuthenticate::class, PrepareAuthenticatedSession::class, ])); } /** * Destroy an authenticated session. * * @param \Illuminate\Http\Request $request * @return \Laravel\Fortify\Contracts\LogoutResponse */ public function destroy(Request $request): LogoutResponse { $this->guard->logout(); if ($request->hasSession()) { $request->session()->invalidate(); $request->session()->regenerateToken(); } return app(LogoutResponse::class); } } src/Http/Controllers/ConfirmedPasswordStatusController.php 0000755 00000001140 00000000000 0020132 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Routing\Controller; class ConfirmedPasswordStatusController extends Controller { /** * Get the password confirmation status. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse */ public function show(Request $request) { return response()->json([ 'confirmed' => (time() - $request->session()->get('auth.password_confirmed_at', 0)) < $request->input('seconds', config('auth.password_timeout', 900)), ]); } } src/Http/Controllers/RecoveryCodeController.php 0000755 00000002420 00000000000 0015670 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Laravel\Fortify\Actions\GenerateNewRecoveryCodes; use Laravel\Fortify\Contracts\RecoveryCodesGeneratedResponse; class RecoveryCodeController extends Controller { /** * Get the two factor authentication recovery codes for authenticated user. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function index(Request $request) { if (! $request->user()->two_factor_secret || ! $request->user()->two_factor_recovery_codes) { return []; } return response()->json(json_decode(decrypt( $request->user()->two_factor_recovery_codes ), true)); } /** * Generate a fresh set of two factor authentication recovery codes. * * @param \Illuminate\Http\Request $request * @param \Laravel\Fortify\Actions\GenerateNewRecoveryCodes $generate * @return \Laravel\Fortify\Contracts\RecoveryCodesGeneratedResponse */ public function store(Request $request, GenerateNewRecoveryCodes $generate) { $generate($request->user()); return app(RecoveryCodesGeneratedResponse::class); } } src/Http/Controllers/EmailVerificationNotificationController.php 0000755 00000001633 00000000000 0021245 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Laravel\Fortify\Contracts\EmailVerificationNotificationSentResponse; use Laravel\Fortify\Fortify; class EmailVerificationNotificationController extends Controller { /** * Send a new email verification notification. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { if ($request->user()->hasVerifiedEmail()) { return $request->wantsJson() ? new JsonResponse('', 204) : redirect()->intended(Fortify::redirects('email-verification')); } $request->user()->sendEmailVerificationNotification(); return app(EmailVerificationNotificationSentResponse::class); } } src/Http/Controllers/NewPasswordController.php 0000755 00000005771 00000000000 0015567 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Contracts\Auth\PasswordBroker; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Contracts\Support\Responsable; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Password; use Laravel\Fortify\Actions\CompletePasswordReset; use Laravel\Fortify\Contracts\FailedPasswordResetResponse; use Laravel\Fortify\Contracts\PasswordResetResponse; use Laravel\Fortify\Contracts\ResetPasswordViewResponse; use Laravel\Fortify\Contracts\ResetsUserPasswords; use Laravel\Fortify\Fortify; class NewPasswordController extends Controller { /** * The guard implementation. * * @var \Illuminate\Contracts\Auth\StatefulGuard */ protected $guard; /** * Create a new controller instance. * * @param \Illuminate\Contracts\Auth\StatefulGuard $guard * @return void */ public function __construct(StatefulGuard $guard) { $this->guard = $guard; } /** * Show the new password view. * * @param \Illuminate\Http\Request $request * @return \Laravel\Fortify\Contracts\ResetPasswordViewResponse */ public function create(Request $request): ResetPasswordViewResponse { return app(ResetPasswordViewResponse::class); } /** * Reset the user's password. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Contracts\Support\Responsable */ public function store(Request $request): Responsable { $request->validate([ 'token' => 'required', Fortify::email() => 'required|email', 'password' => 'required', ]); // Here we will attempt to reset the user's password. If it is successful we // will update the password on an actual user model and persist it to the // database. Otherwise we will parse the error and return the response. $status = $this->broker()->reset( $request->only(Fortify::email(), 'password', 'password_confirmation', 'token'), function ($user) use ($request) { app(ResetsUserPasswords::class)->reset($user, $request->all()); app(CompletePasswordReset::class)($this->guard, $user); } ); // If the password was successfully reset, we will redirect the user back to // the application's home authenticated view. If there is an error we can // redirect them back to where they came from with their error message. return $status == Password::PASSWORD_RESET ? app(PasswordResetResponse::class, ['status' => $status]) : app(FailedPasswordResetResponse::class, ['status' => $status]); } /** * Get the broker to be used during password reset. * * @return \Illuminate\Contracts\Auth\PasswordBroker */ protected function broker(): PasswordBroker { return Password::broker(config('fortify.passwords')); } } src/Http/Controllers/TwoFactorQrCodeController.php 0000755 00000001271 00000000000 0016310 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Routing\Controller; class TwoFactorQrCodeController extends Controller { /** * Get the SVG element for the user's two factor authentication QR code. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function show(Request $request) { if (is_null($request->user()->two_factor_secret)) { return []; } return response()->json([ 'svg' => $request->user()->twoFactorQrCodeSvg(), 'url' => $request->user()->twoFactorQrCodeUrl(), ]); } } src/Http/Controllers/TwoFactorSecretKeyController.php 0000755 00000001276 00000000000 0017036 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Routing\Controller; class TwoFactorSecretKeyController extends Controller { /** * Get the current user's two factor authentication setup / secret key. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function show(Request $request) { if (is_null($request->user()->two_factor_secret)) { abort(404, 'Two factor authentication has not been enabled.'); } return response()->json([ 'secretKey' => decrypt($request->user()->two_factor_secret), ]); } } src/Http/Controllers/TwoFactorAuthenticatedSessionController.php 0000755 00000004256 00000000000 0021267 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Http\Exceptions\HttpResponseException; use Illuminate\Routing\Controller; use Laravel\Fortify\Contracts\FailedTwoFactorLoginResponse; use Laravel\Fortify\Contracts\TwoFactorChallengeViewResponse; use Laravel\Fortify\Contracts\TwoFactorLoginResponse; use Laravel\Fortify\Events\RecoveryCodeReplaced; use Laravel\Fortify\Http\Requests\TwoFactorLoginRequest; class TwoFactorAuthenticatedSessionController extends Controller { /** * The guard implementation. * * @var \Illuminate\Contracts\Auth\StatefulGuard */ protected $guard; /** * Create a new controller instance. * * @param \Illuminate\Contracts\Auth\StatefulGuard $guard * @return void */ public function __construct(StatefulGuard $guard) { $this->guard = $guard; } /** * Show the two factor authentication challenge view. * * @param \Laravel\Fortify\Http\Requests\TwoFactorLoginRequest $request * @return \Laravel\Fortify\Contracts\TwoFactorChallengeViewResponse */ public function create(TwoFactorLoginRequest $request): TwoFactorChallengeViewResponse { if (! $request->hasChallengedUser()) { throw new HttpResponseException(redirect()->route('login')); } return app(TwoFactorChallengeViewResponse::class); } /** * Attempt to authenticate a new session using the two factor authentication code. * * @param \Laravel\Fortify\Http\Requests\TwoFactorLoginRequest $request * @return mixed */ public function store(TwoFactorLoginRequest $request) { $user = $request->challengedUser(); if ($code = $request->validRecoveryCode()) { $user->replaceRecoveryCode($code); event(new RecoveryCodeReplaced($user, $code)); } elseif (! $request->hasValidCode()) { return app(FailedTwoFactorLoginResponse::class)->toResponse($request); } $this->guard->login($user, $request->remember()); $request->session()->regenerate(); return app(TwoFactorLoginResponse::class); } } src/Http/Controllers/PasswordResetLinkController.php 0000755 00000004045 00000000000 0016727 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Contracts\Auth\PasswordBroker; use Illuminate\Contracts\Support\Responsable; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Password; use Laravel\Fortify\Contracts\FailedPasswordResetLinkRequestResponse; use Laravel\Fortify\Contracts\RequestPasswordResetLinkViewResponse; use Laravel\Fortify\Contracts\SuccessfulPasswordResetLinkRequestResponse; use Laravel\Fortify\Fortify; class PasswordResetLinkController extends Controller { /** * Show the reset password link request view. * * @param \Illuminate\Http\Request $request * @return \Laravel\Fortify\Contracts\RequestPasswordResetLinkViewResponse */ public function create(Request $request): RequestPasswordResetLinkViewResponse { return app(RequestPasswordResetLinkViewResponse::class); } /** * Send a reset link to the given user. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Contracts\Support\Responsable */ public function store(Request $request): Responsable { $request->validate([Fortify::email() => 'required|email']); // We will send the password reset link to this user. Once we have attempted // to send the link, we will examine the response then see the message we // need to show to the user. Finally, we'll send out a proper response. $status = $this->broker()->sendResetLink( $request->only(Fortify::email()) ); return $status == Password::RESET_LINK_SENT ? app(SuccessfulPasswordResetLinkRequestResponse::class, ['status' => $status]) : app(FailedPasswordResetLinkRequestResponse::class, ['status' => $status]); } /** * Get the broker to be used during password reset. * * @return \Illuminate\Contracts\Auth\PasswordBroker */ protected function broker(): PasswordBroker { return Password::broker(config('fortify.passwords')); } } src/Http/Controllers/RegisteredUserController.php 0000755 00000003473 00000000000 0016244 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Auth\Events\Registered; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Illuminate\Support\Str; use Laravel\Fortify\Contracts\CreatesNewUsers; use Laravel\Fortify\Contracts\RegisterResponse; use Laravel\Fortify\Contracts\RegisterViewResponse; use Laravel\Fortify\Fortify; class RegisteredUserController extends Controller { /** * The guard implementation. * * @var \Illuminate\Contracts\Auth\StatefulGuard */ protected $guard; /** * Create a new controller instance. * * @param \Illuminate\Contracts\Auth\StatefulGuard $guard * @return void */ public function __construct(StatefulGuard $guard) { $this->guard = $guard; } /** * Show the registration view. * * @param \Illuminate\Http\Request $request * @return \Laravel\Fortify\Contracts\RegisterViewResponse */ public function create(Request $request): RegisterViewResponse { return app(RegisterViewResponse::class); } /** * Create a new registered user. * * @param \Illuminate\Http\Request $request * @param \Laravel\Fortify\Contracts\CreatesNewUsers $creator * @return \Laravel\Fortify\Contracts\RegisterResponse */ public function store(Request $request, CreatesNewUsers $creator): RegisterResponse { if (config('fortify.lowercase_usernames')) { $request->merge([ Fortify::username() => Str::lower($request->{Fortify::username()}), ]); } event(new Registered($user = $creator->create($request->all()))); $this->guard->login($user); return app(RegisterResponse::class); } } src/Http/Controllers/ConfirmablePasswordController.php 0000755 00000003403 00000000000 0017245 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Date; use Laravel\Fortify\Actions\ConfirmPassword; use Laravel\Fortify\Contracts\ConfirmPasswordViewResponse; use Laravel\Fortify\Contracts\FailedPasswordConfirmationResponse; use Laravel\Fortify\Contracts\PasswordConfirmedResponse; class ConfirmablePasswordController extends Controller { /** * The guard implementation. * * @var \Illuminate\Contracts\Auth\StatefulGuard */ protected $guard; /** * Create a new controller instance. * * @param \Illuminate\Contracts\Auth\StatefulGuard $guard * @return void */ public function __construct(StatefulGuard $guard) { $this->guard = $guard; } /** * Show the confirm password view. * * @param \Illuminate\Http\Request $request * @return \Laravel\Fortify\Contracts\ConfirmPasswordViewResponse */ public function show(Request $request) { return app(ConfirmPasswordViewResponse::class); } /** * Confirm the user's password. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Contracts\Support\Responsable */ public function store(Request $request) { $confirmed = app(ConfirmPassword::class)( $this->guard, $request->user(), $request->input('password') ); if ($confirmed) { $request->session()->put('auth.password_confirmed_at', Date::now()->unix()); } return $confirmed ? app(PasswordConfirmedResponse::class) : app(FailedPasswordConfirmationResponse::class); } } src/Http/Controllers/TwoFactorAuthenticationController.php 0000755 00000002534 00000000000 0020115 0 ustar 00 <?php namespace Laravel\Fortify\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Laravel\Fortify\Actions\DisableTwoFactorAuthentication; use Laravel\Fortify\Actions\EnableTwoFactorAuthentication; use Laravel\Fortify\Contracts\TwoFactorDisabledResponse; use Laravel\Fortify\Contracts\TwoFactorEnabledResponse; class TwoFactorAuthenticationController extends Controller { /** * Enable two factor authentication for the user. * * @param \Illuminate\Http\Request $request * @param \Laravel\Fortify\Actions\EnableTwoFactorAuthentication $enable * @return \Laravel\Fortify\Contracts\TwoFactorEnabledResponse */ public function store(Request $request, EnableTwoFactorAuthentication $enable) { $enable($request->user(), $request->boolean('force', false)); return app(TwoFactorEnabledResponse::class); } /** * Disable two factor authentication for the user. * * @param \Illuminate\Http\Request $request * @param \Laravel\Fortify\Actions\DisableTwoFactorAuthentication $disable * @return \Laravel\Fortify\Contracts\TwoFactorDisabledResponse */ public function destroy(Request $request, DisableTwoFactorAuthentication $disable) { $disable($request->user()); return app(TwoFactorDisabledResponse::class); } } src/Http/Requests/TwoFactorLoginRequest.php 0000755 00000006550 00000000000 0015022 0 ustar 00 <?php namespace Laravel\Fortify\Http\Requests; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Http\Exceptions\HttpResponseException; use Laravel\Fortify\Contracts\FailedTwoFactorLoginResponse; use Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider; class TwoFactorLoginRequest extends FormRequest { /** * The user attempting the two factor challenge. * * @var mixed */ protected $challengedUser; /** * Indicates if the user wished to be remembered after login. * * @var bool */ protected $remember; /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'code' => 'nullable|string', 'recovery_code' => 'nullable|string', ]; } /** * Determine if the request has a valid two factor code. * * @return bool */ public function hasValidCode() { return $this->code && tap(app(TwoFactorAuthenticationProvider::class)->verify( decrypt($this->challengedUser()->two_factor_secret), $this->code ), function ($result) { if ($result) { $this->session()->forget('login.id'); } }); } /** * Get the valid recovery code if one exists on the request. * * @return string|null */ public function validRecoveryCode() { if (! $this->recovery_code) { return; } return tap(collect($this->challengedUser()->recoveryCodes())->first(function ($code) { return hash_equals($code, $this->recovery_code) ? $code : null; }), function ($code) { if ($code) { $this->session()->forget('login.id'); } }); } /** * Determine if there is a challenged user in the current session. * * @return bool */ public function hasChallengedUser() { if ($this->challengedUser) { return true; } $model = app(StatefulGuard::class)->getProvider()->getModel(); return $this->session()->has('login.id') && $model::find($this->session()->get('login.id')); } /** * Get the user that is attempting the two factor challenge. * * @return mixed */ public function challengedUser() { if ($this->challengedUser) { return $this->challengedUser; } $model = app(StatefulGuard::class)->getProvider()->getModel(); if (! $this->session()->has('login.id') || ! $user = $model::find($this->session()->get('login.id'))) { throw new HttpResponseException( app(FailedTwoFactorLoginResponse::class)->toResponse($this) ); } return $this->challengedUser = $user; } /** * Determine if the user wanted to be remembered after login. * * @return bool */ public function remember() { if (! $this->remember) { $this->remember = $this->session()->pull('login.remember', false); } return $this->remember; } } src/Http/Requests/LoginRequest.php 0000755 00000001142 00000000000 0013161 0 ustar 00 <?php namespace Laravel\Fortify\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Laravel\Fortify\Fortify; class LoginRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ Fortify::username() => 'required|string', 'password' => 'required|string', ]; } } src/Http/Requests/VerifyEmailRequest.php 0000755 00000001361 00000000000 0014330 0 ustar 00 <?php namespace Laravel\Fortify\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class VerifyEmailRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { if (! hash_equals((string) $this->user()->getKey(), (string) $this->route('id'))) { return false; } if (! hash_equals(sha1($this->user()->getEmailForVerification()), (string) $this->route('hash'))) { return false; } return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return []; } } src/Fortify.php 0000755 00000021773 00000000000 0007444 0 ustar 00 <?php namespace Laravel\Fortify; use Laravel\Fortify\Contracts\ConfirmPasswordViewResponse; use Laravel\Fortify\Contracts\CreatesNewUsers; use Laravel\Fortify\Contracts\LoginViewResponse; 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; /** * Indicates if Fortify routes will be registered. * * @var bool */ public static $registersRoutes = true; 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 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 string $callback * @return void */ public static function createUsersUsing(string $callback) { app()->singleton(CreatesNewUsers::class, $callback); } /** * Register a class / callback that should be used to update user profile information. * * @param string $callback * @return void */ public static function updateUserProfileInformationUsing(string $callback) { app()->singleton(UpdatesUserProfileInformation::class, $callback); } /** * Register a class / callback that should be used to update user passwords. * * @param string $callback * @return void */ public static function updateUserPasswordsUsing(string $callback) { app()->singleton(UpdatesUserPasswords::class, $callback); } /** * Register a class / callback that should be used to reset user passwords. * * @param string $callback * @return void */ public static function resetUserPasswordsUsing(string $callback) { app()->singleton(ResetsUserPasswords::class, $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'); } /** * Configure Fortify to not register its routes. * * @return static */ public static function ignoreRoutes() { static::$registersRoutes = false; return new static; } } src/TwoFactorAuthenticationProvider.php 0000755 00000004514 00000000000 0014337 0 ustar 00 <?php namespace Laravel\Fortify; use Illuminate\Contracts\Cache\Repository; use Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider as TwoFactorAuthenticationProviderContract; use PragmaRX\Google2FA\Google2FA; class TwoFactorAuthenticationProvider implements TwoFactorAuthenticationProviderContract { /** * The underlying library providing two factor authentication helper services. * * @var \PragmaRX\Google2FA\Google2FA */ protected $engine; /** * The cache repository implementation. * * @var \Illuminate\Contracts\Cache\Repository|null */ protected $cache; /** * Create a new two factor authentication provider instance. * * @param \PragmaRX\Google2FA\Google2FA $engine * @param \Illuminate\Contracts\Cache\Repository|null $cache * @return void */ public function __construct(Google2FA $engine, Repository $cache = null) { $this->engine = $engine; $this->cache = $cache; } /** * Generate a new secret key. * * @return string */ public function generateSecretKey() { return $this->engine->generateSecretKey(); } /** * Get the two factor authentication QR code URL. * * @param string $companyName * @param string $companyEmail * @param string $secret * @return string */ public function qrCodeUrl($companyName, $companyEmail, $secret) { return $this->engine->getQRCodeUrl($companyName, $companyEmail, $secret); } /** * Verify the given code. * * @param string $secret * @param string $code * @return bool */ public function verify($secret, $code) { if (is_int($customWindow = config('fortify-options.two-factor-authentication.window'))) { $this->engine->setWindow($customWindow); } $timestamp = $this->engine->verifyKeyNewer( $secret, $code, optional($this->cache)->get($key = 'fortify.2fa_codes.'.md5($code)) ); if ($timestamp !== false) { if ($timestamp === true) { $timestamp = $this->engine->getTimestamp(); } optional($this->cache)->put($key, $timestamp, ($this->engine->getWindow() ?: 1) * 60); return true; } return false; } } src/FortifyServiceProvider.php 0000755 00000021447 00000000000 0012476 0 ustar 00 <?php namespace Laravel\Fortify; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Contracts\Cache\Repository; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; use Laravel\Fortify\Contracts\EmailVerificationNotificationSentResponse as EmailVerificationNotificationSentResponseContract; use Laravel\Fortify\Contracts\FailedPasswordConfirmationResponse as FailedPasswordConfirmationResponseContract; use Laravel\Fortify\Contracts\FailedPasswordResetLinkRequestResponse as FailedPasswordResetLinkRequestResponseContract; use Laravel\Fortify\Contracts\FailedPasswordResetResponse as FailedPasswordResetResponseContract; use Laravel\Fortify\Contracts\FailedTwoFactorLoginResponse as FailedTwoFactorLoginResponseContract; use Laravel\Fortify\Contracts\LockoutResponse as LockoutResponseContract; use Laravel\Fortify\Contracts\LoginResponse as LoginResponseContract; use Laravel\Fortify\Contracts\LogoutResponse as LogoutResponseContract; use Laravel\Fortify\Contracts\PasswordConfirmedResponse as PasswordConfirmedResponseContract; use Laravel\Fortify\Contracts\PasswordResetResponse as PasswordResetResponseContract; use Laravel\Fortify\Contracts\PasswordUpdateResponse as PasswordUpdateResponseContract; use Laravel\Fortify\Contracts\ProfileInformationUpdatedResponse as ProfileInformationUpdatedResponseContract; use Laravel\Fortify\Contracts\RecoveryCodesGeneratedResponse as RecoveryCodesGeneratedResponseContract; use Laravel\Fortify\Contracts\RegisterResponse as RegisterResponseContract; use Laravel\Fortify\Contracts\SuccessfulPasswordResetLinkRequestResponse as SuccessfulPasswordResetLinkRequestResponseContract; use Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider as TwoFactorAuthenticationProviderContract; use Laravel\Fortify\Contracts\TwoFactorConfirmedResponse as TwoFactorConfirmedResponseContract; use Laravel\Fortify\Contracts\TwoFactorDisabledResponse as TwoFactorDisabledResponseContract; use Laravel\Fortify\Contracts\TwoFactorEnabledResponse as TwoFactorEnabledResponseContract; use Laravel\Fortify\Contracts\TwoFactorLoginResponse as TwoFactorLoginResponseContract; use Laravel\Fortify\Contracts\VerifyEmailResponse as VerifyEmailResponseContract; use Laravel\Fortify\Http\Responses\EmailVerificationNotificationSentResponse; use Laravel\Fortify\Http\Responses\FailedPasswordConfirmationResponse; use Laravel\Fortify\Http\Responses\FailedPasswordResetLinkRequestResponse; use Laravel\Fortify\Http\Responses\FailedPasswordResetResponse; use Laravel\Fortify\Http\Responses\FailedTwoFactorLoginResponse; use Laravel\Fortify\Http\Responses\LockoutResponse; use Laravel\Fortify\Http\Responses\LoginResponse; use Laravel\Fortify\Http\Responses\LogoutResponse; use Laravel\Fortify\Http\Responses\PasswordConfirmedResponse; use Laravel\Fortify\Http\Responses\PasswordResetResponse; use Laravel\Fortify\Http\Responses\PasswordUpdateResponse; use Laravel\Fortify\Http\Responses\ProfileInformationUpdatedResponse; use Laravel\Fortify\Http\Responses\RecoveryCodesGeneratedResponse; use Laravel\Fortify\Http\Responses\RegisterResponse; use Laravel\Fortify\Http\Responses\SuccessfulPasswordResetLinkRequestResponse; use Laravel\Fortify\Http\Responses\TwoFactorConfirmedResponse; use Laravel\Fortify\Http\Responses\TwoFactorDisabledResponse; use Laravel\Fortify\Http\Responses\TwoFactorEnabledResponse; use Laravel\Fortify\Http\Responses\TwoFactorLoginResponse; use Laravel\Fortify\Http\Responses\VerifyEmailResponse; use PragmaRX\Google2FA\Google2FA; class FortifyServiceProvider extends ServiceProvider { /** * Register any application services. * * @return void */ public function register() { $this->mergeConfigFrom(__DIR__.'/../config/fortify.php', 'fortify'); $this->registerResponseBindings(); $this->app->singleton(TwoFactorAuthenticationProviderContract::class, function ($app) { return new TwoFactorAuthenticationProvider( $app->make(Google2FA::class), $app->make(Repository::class) ); }); $this->app->bind(StatefulGuard::class, function () { return Auth::guard(config('fortify.guard', null)); }); } /** * Register the response bindings. * * @return void */ protected function registerResponseBindings() { $this->app->singleton(FailedPasswordConfirmationResponseContract::class, FailedPasswordConfirmationResponse::class); $this->app->singleton(FailedPasswordResetLinkRequestResponseContract::class, FailedPasswordResetLinkRequestResponse::class); $this->app->singleton(FailedPasswordResetResponseContract::class, FailedPasswordResetResponse::class); $this->app->singleton(FailedTwoFactorLoginResponseContract::class, FailedTwoFactorLoginResponse::class); $this->app->singleton(LockoutResponseContract::class, LockoutResponse::class); $this->app->singleton(LoginResponseContract::class, LoginResponse::class); $this->app->singleton(LogoutResponseContract::class, LogoutResponse::class); $this->app->singleton(PasswordConfirmedResponseContract::class, PasswordConfirmedResponse::class); $this->app->singleton(PasswordResetResponseContract::class, PasswordResetResponse::class); $this->app->singleton(PasswordUpdateResponseContract::class, PasswordUpdateResponse::class); $this->app->singleton(ProfileInformationUpdatedResponseContract::class, ProfileInformationUpdatedResponse::class); $this->app->singleton(RecoveryCodesGeneratedResponseContract::class, RecoveryCodesGeneratedResponse::class); $this->app->singleton(RegisterResponseContract::class, RegisterResponse::class); $this->app->singleton(EmailVerificationNotificationSentResponseContract::class, EmailVerificationNotificationSentResponse::class); $this->app->singleton(SuccessfulPasswordResetLinkRequestResponseContract::class, SuccessfulPasswordResetLinkRequestResponse::class); $this->app->singleton(TwoFactorConfirmedResponseContract::class, TwoFactorConfirmedResponse::class); $this->app->singleton(TwoFactorDisabledResponseContract::class, TwoFactorDisabledResponse::class); $this->app->singleton(TwoFactorEnabledResponseContract::class, TwoFactorEnabledResponse::class); $this->app->singleton(TwoFactorLoginResponseContract::class, TwoFactorLoginResponse::class); $this->app->singleton(VerifyEmailResponseContract::class, VerifyEmailResponse::class); } /** * Bootstrap any application services. * * @return void */ public function boot() { $this->configurePublishing(); $this->configureRoutes(); $this->registerCommands(); } /** * Configure the publishable resources offered by the package. * * @return void */ protected function configurePublishing() { if ($this->app->runningInConsole()) { $this->publishes([ __DIR__.'/../stubs/fortify.php' => config_path('fortify.php'), ], 'fortify-config'); $this->publishes([ __DIR__.'/../stubs/CreateNewUser.php' => app_path('Actions/Fortify/CreateNewUser.php'), __DIR__.'/../stubs/FortifyServiceProvider.php' => app_path('Providers/FortifyServiceProvider.php'), __DIR__.'/../stubs/PasswordValidationRules.php' => app_path('Actions/Fortify/PasswordValidationRules.php'), __DIR__.'/../stubs/ResetUserPassword.php' => app_path('Actions/Fortify/ResetUserPassword.php'), __DIR__.'/../stubs/UpdateUserProfileInformation.php' => app_path('Actions/Fortify/UpdateUserProfileInformation.php'), __DIR__.'/../stubs/UpdateUserPassword.php' => app_path('Actions/Fortify/UpdateUserPassword.php'), ], 'fortify-support'); $method = method_exists($this, 'publishesMigrations') ? 'publishesMigrations' : 'publishes'; $this->{$method}([ __DIR__.'/../database/migrations' => database_path('migrations'), ], 'fortify-migrations'); } } /** * Configure the routes offered by the application. * * @return void */ protected function configureRoutes() { if (Fortify::$registersRoutes) { Route::group([ 'namespace' => 'Laravel\Fortify\Http\Controllers', 'domain' => config('fortify.domain', null), 'prefix' => config('fortify.prefix'), ], function () { $this->loadRoutesFrom(__DIR__.'/../routes/routes.php'); }); } } /** * Register the package's commands. */ protected function registerCommands(): void { if ($this->app->runningInConsole()) { $this->commands([ Console\InstallCommand::class, ]); } } } src/Rules/Password.php 0000755 00000012573 00000000000 0010714 0 ustar 00 <?php namespace Laravel\Fortify\Rules; use Illuminate\Contracts\Validation\Rule; use Illuminate\Support\Str; /** * @deprecated Use \Illuminate\Validation\Rules\Password instead. */ class Password implements Rule { /** * The minimum length of the password. * * @var int */ protected $length = 8; /** * Indicates if the password must contain one uppercase character. * * @var bool */ protected $requireUppercase = false; /** * Indicates if the password must contain one numeric digit. * * @var bool */ protected $requireNumeric = false; /** * Indicates if the password must contain one special character. * * @var bool */ protected $requireSpecialCharacter = false; /** * The message that should be used when validation fails. * * @var string */ protected $message; /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { $value = is_scalar($value) ? (string) $value : ''; if ($this->requireUppercase && Str::lower($value) === $value) { return false; } if ($this->requireNumeric && ! preg_match('/[0-9]/', $value)) { return false; } if ($this->requireSpecialCharacter && ! preg_match('/[\W_]/', $value)) { return false; } return Str::length($value) >= $this->length; } /** * Get the validation error message. * * @return string */ public function message() { if ($this->message) { return $this->message; } switch (true) { case $this->requireUppercase && ! $this->requireNumeric && ! $this->requireSpecialCharacter: return __('The :attribute must be at least :length characters and contain at least one uppercase character.', [ 'length' => $this->length, ]); case $this->requireNumeric && ! $this->requireUppercase && ! $this->requireSpecialCharacter: return __('The :attribute must be at least :length characters and contain at least one number.', [ 'length' => $this->length, ]); case $this->requireSpecialCharacter && ! $this->requireUppercase && ! $this->requireNumeric: return __('The :attribute must be at least :length characters and contain at least one special character.', [ 'length' => $this->length, ]); case $this->requireUppercase && $this->requireNumeric && ! $this->requireSpecialCharacter: return __('The :attribute must be at least :length characters and contain at least one uppercase character and one number.', [ 'length' => $this->length, ]); case $this->requireUppercase && $this->requireSpecialCharacter && ! $this->requireNumeric: return __('The :attribute must be at least :length characters and contain at least one uppercase character and one special character.', [ 'length' => $this->length, ]); case $this->requireUppercase && $this->requireNumeric && $this->requireSpecialCharacter: return __('The :attribute must be at least :length characters and contain at least one uppercase character, one number, and one special character.', [ 'length' => $this->length, ]); case $this->requireNumeric && $this->requireSpecialCharacter && ! $this->requireUppercase: return __('The :attribute must be at least :length characters and contain at least one special character and one number.', [ 'length' => $this->length, ]); default: return __('The :attribute must be at least :length characters.', [ 'length' => $this->length, ]); } } /** * Set the minimum length of the password. * * @param int $length * @return $this */ public function length(int $length) { $this->length = $length; return $this; } /** * Indicate that at least one uppercase character is required. * * @return $this */ public function requireUppercase() { $this->requireUppercase = true; return $this; } /** * Indicate that at least one numeric digit is required. * * @return $this */ public function requireNumeric() { $this->requireNumeric = true; return $this; } /** * Indicate that at least one special character is required. * * @return $this */ public function requireSpecialCharacter() { $this->requireSpecialCharacter = true; return $this; } /** * Set the message that should be used when the rule fails. * * @param string $message * @return $this */ public function withMessage(string $message) { $this->message = $message; return $this; } } src/LoginRateLimiter.php 0000755 00000004344 00000000000 0011227 0 ustar 00 <?php namespace Laravel\Fortify; use Illuminate\Cache\RateLimiter; use Illuminate\Http\Request; use Illuminate\Support\Str; class LoginRateLimiter { /** * The login rate limiter instance. * * @var \Illuminate\Cache\RateLimiter */ protected $limiter; /** * Create a new login rate limiter instance. * * @param \Illuminate\Cache\RateLimiter $limiter * @return void */ public function __construct(RateLimiter $limiter) { $this->limiter = $limiter; } /** * Get the number of attempts for the given key. * * @param \Illuminate\Http\Request $request * @return mixed */ public function attempts(Request $request) { return $this->limiter->attempts($this->throttleKey($request)); } /** * Determine if the user has too many failed login attempts. * * @param \Illuminate\Http\Request $request * @return bool */ public function tooManyAttempts(Request $request) { return $this->limiter->tooManyAttempts($this->throttleKey($request), 5); } /** * Increment the login attempts for the user. * * @param \Illuminate\Http\Request $request * @return void */ public function increment(Request $request) { $this->limiter->hit($this->throttleKey($request), 60); } /** * Determine the number of seconds until logging in is available again. * * @param \Illuminate\Http\Request $request * @return int */ public function availableIn(Request $request) { return $this->limiter->availableIn($this->throttleKey($request)); } /** * Clear the login locks for the given user credentials. * * @param \Illuminate\Http\Request $request * @return void */ public function clear(Request $request) { $this->limiter->clear($this->throttleKey($request)); } /** * Get the throttle key for the given request. * * @param \Illuminate\Http\Request $request * @return string */ protected function throttleKey(Request $request) { return Str::transliterate(Str::lower($request->input(Fortify::username())).'|'.$request->ip()); } } src/Features.php 0000755 00000006221 00000000000 0007567 0 ustar 00 <?php namespace Laravel\Fortify; class Features { /** * Determine if the given feature is enabled. * * @param string $feature * @return bool */ public static function enabled(string $feature) { return in_array($feature, config('fortify.features', [])); } /** * Determine if the feature is enabled and has a given option enabled. * * @param string $feature * @param string $option * @return bool */ public static function optionEnabled(string $feature, string $option) { return static::enabled($feature) && config("fortify-options.{$feature}.{$option}") === true; } /** * Determine if the application is using any features that require "profile" management. * * @return bool */ public static function hasProfileFeatures() { return static::enabled(static::updateProfileInformation()) || static::enabled(static::updatePasswords()) || static::enabled(static::twoFactorAuthentication()); } /** * Determine if the application can update a user's profile information. * * @return bool */ public static function canUpdateProfileInformation() { return static::enabled(static::updateProfileInformation()); } /** * Determine if the application is using any security profile features. * * @return bool */ public static function hasSecurityFeatures() { return static::enabled(static::updatePasswords()) || static::canManageTwoFactorAuthentication(); } /** * Determine if the application can manage two factor authentication. * * @return bool */ public static function canManageTwoFactorAuthentication() { return static::enabled(static::twoFactorAuthentication()); } /** * Enable the registration feature. * * @return string */ public static function registration() { return 'registration'; } /** * Enable the password reset feature. * * @return string */ public static function resetPasswords() { return 'reset-passwords'; } /** * Enable the email verification feature. * * @return string */ public static function emailVerification() { return 'email-verification'; } /** * Enable the update profile information feature. * * @return string */ public static function updateProfileInformation() { return 'update-profile-information'; } /** * Enable the update password feature. * * @return string */ public static function updatePasswords() { return 'update-passwords'; } /** * Enable the two factor authentication feature. * * @param array $options * @return string */ public static function twoFactorAuthentication(array $options = []) { if (! empty($options)) { config(['fortify-options.two-factor-authentication' => $options]); } return 'two-factor-authentication'; } } src/Contracts/VerifyEmailResponse.php 0000755 00000000231 00000000000 0013677 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface VerifyEmailResponse extends Responsable { // } src/Contracts/ConfirmPasswordViewResponse.php 0000755 00000000241 00000000000 0015437 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface ConfirmPasswordViewResponse extends Responsable { // } src/Contracts/ProfileInformationUpdatedResponse.php 0000755 00000000247 00000000000 0016607 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface ProfileInformationUpdatedResponse extends Responsable { // } src/Contracts/RequestPasswordResetLinkViewResponse.php 0000755 00000000252 00000000000 0017315 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface RequestPasswordResetLinkViewResponse extends Responsable { // } src/Contracts/PasswordConfirmedResponse.php 0000755 00000000237 00000000000 0015122 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface PasswordConfirmedResponse extends Responsable { // } src/Contracts/ResetPasswordViewResponse.php 0000755 00000000237 00000000000 0015131 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface ResetPasswordViewResponse extends Responsable { // } src/Contracts/ResetsUserPasswords.php 0000755 00000000252 00000000000 0013761 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; /** * @method void reset(\Illuminate\Foundation\Auth\User $user, array $input) */ interface ResetsUserPasswords { // } src/Contracts/TwoFactorConfirmedResponse.php 0000755 00000000240 00000000000 0015222 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface TwoFactorConfirmedResponse extends Responsable { // } src/Contracts/RecoveryCodesGeneratedResponse.php 0000755 00000000244 00000000000 0016062 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface RecoveryCodesGeneratedResponse extends Responsable { // } src/Contracts/FailedPasswordResetResponse.php 0000755 00000000241 00000000000 0015376 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface FailedPasswordResetResponse extends Responsable { // } src/Contracts/TwoFactorLoginResponse.php 0000755 00000000234 00000000000 0014367 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface TwoFactorLoginResponse extends Responsable { // } src/Contracts/UpdatesUserProfileInformation.php 0000755 00000000265 00000000000 0015746 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; /** * @method void update(\Illuminate\Foundation\Auth\User $user, array $input) */ interface UpdatesUserProfileInformation { // } src/Contracts/EmailVerificationNotificationSentResponse.php 0000755 00000000257 00000000000 0020266 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface EmailVerificationNotificationSentResponse extends Responsable { // } src/Contracts/LogoutResponse.php 0000755 00000000224 00000000000 0012736 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface LogoutResponse extends Responsable { // } src/Contracts/TwoFactorDisabledResponse.php 0000755 00000000237 00000000000 0015031 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface TwoFactorDisabledResponse extends Responsable { // } src/Contracts/TwoFactorAuthenticationProvider.php 0000755 00000001227 00000000000 0016275 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; interface TwoFactorAuthenticationProvider { /** * Generate a new secret key. * * @return string */ public function generateSecretKey(); /** * Get the two factor authentication QR code URL. * * @param string $companyName * @param string $companyEmail * @param string $secret * @return string */ public function qrCodeUrl($companyName, $companyEmail, $secret); /** * Verify the given token. * * @param string $secret * @param string $code * @return bool */ public function verify($secret, $code); } src/Contracts/PasswordResetResponse.php 0000755 00000000233 00000000000 0014272 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface PasswordResetResponse extends Responsable { // } src/Contracts/PasswordUpdateResponse.php 0000755 00000000234 00000000000 0014433 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface PasswordUpdateResponse extends Responsable { // } src/Contracts/RegisterViewResponse.php 0000755 00000000232 00000000000 0014103 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface RegisterViewResponse extends Responsable { // } src/Contracts/TwoFactorEnabledResponse.php 0000755 00000000236 00000000000 0014653 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface TwoFactorEnabledResponse extends Responsable { // } src/Contracts/SuccessfulPasswordResetLinkRequestResponse.php 0000755 00000000260 00000000000 0020521 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface SuccessfulPasswordResetLinkRequestResponse extends Responsable { // } src/Contracts/LoginViewResponse.php 0000755 00000000227 00000000000 0013373 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface LoginViewResponse extends Responsable { // } src/Contracts/FailedTwoFactorLoginResponse.php 0000755 00000000242 00000000000 0015473 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface FailedTwoFactorLoginResponse extends Responsable { // } src/Contracts/TwoFactorChallengeViewResponse.php 0000755 00000000244 00000000000 0016035 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface TwoFactorChallengeViewResponse extends Responsable { // } src/Contracts/UpdatesUserPasswords.php 0000755 00000000254 00000000000 0014123 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; /** * @method void update(\Illuminate\Foundation\Auth\User $user, array $input) */ interface UpdatesUserPasswords { // } src/Contracts/FailedPasswordResetLinkRequestResponse.php 0000755 00000000254 00000000000 0017571 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface FailedPasswordResetLinkRequestResponse extends Responsable { // } src/Contracts/RegisterResponse.php 0000755 00000000226 00000000000 0013253 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface RegisterResponse extends Responsable { // } src/Contracts/CreatesNewUsers.php 0000755 00000000415 00000000000 0013032 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; interface CreatesNewUsers { /** * Validate and create a newly registered user. * * @param array $input * @return \Illuminate\Foundation\Auth\User */ public function create(array $input); } src/Contracts/FailedPasswordConfirmationResponse.php 0000755 00000000250 00000000000 0016744 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface FailedPasswordConfirmationResponse extends Responsable { // } src/Contracts/LockoutResponse.php 0000755 00000000225 00000000000 0013106 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface LockoutResponse extends Responsable { // } src/Contracts/LoginResponse.php 0000755 00000000223 00000000000 0012534 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface LoginResponse extends Responsable { // } src/Contracts/VerifyEmailViewResponse.php 0000755 00000000235 00000000000 0014536 0 ustar 00 <?php namespace Laravel\Fortify\Contracts; use Illuminate\Contracts\Support\Responsable; interface VerifyEmailViewResponse extends Responsable { // } src/RecoveryCode.php 0000755 00000000417 00000000000 0010403 0 ustar 00 <?php namespace Laravel\Fortify; use Illuminate\Support\Str; class RecoveryCode { /** * Generate a new recovery code. * * @return string */ public static function generate() { return Str::random(10).'-'.Str::random(10); } } src/Events/TwoFactorAuthenticationEvent.php 0000755 00000000710 00000000000 0015064 0 ustar 00 <?php namespace Laravel\Fortify\Events; use Illuminate\Foundation\Events\Dispatchable; abstract class TwoFactorAuthenticationEvent { use Dispatchable; /** * The user instance. * * @var \App\Models\User */ public $user; /** * Create a new event instance. * * @param \App\Models\User $user * @return void */ public function __construct($user) { $this->user = $user; } } src/Events/TwoFactorAuthenticationDisabled.php 0000755 00000000200 00000000000 0015504 0 ustar 00 <?php namespace Laravel\Fortify\Events; class TwoFactorAuthenticationDisabled extends TwoFactorAuthenticationEvent { // } src/Events/RecoveryCodesGenerated.php 0000755 00000000671 00000000000 0013653 0 ustar 00 <?php namespace Laravel\Fortify\Events; use Illuminate\Foundation\Events\Dispatchable; class RecoveryCodesGenerated { use Dispatchable; /** * The user instance. * * @var \App\Models\User */ public $user; /** * Create a new event instance. * * @param \App\Models\User $user * @return void */ public function __construct($user) { $this->user = $user; } } src/Events/TwoFactorAuthenticationConfirmed.php 0000755 00000000201 00000000000 0015704 0 ustar 00 <?php namespace Laravel\Fortify\Events; class TwoFactorAuthenticationConfirmed extends TwoFactorAuthenticationEvent { // } src/Events/RecoveryCodeReplaced.php 0000755 00000001204 00000000000 0013302 0 ustar 00 <?php namespace Laravel\Fortify\Events; use Illuminate\Queue\SerializesModels; class RecoveryCodeReplaced { use SerializesModels; /** * The authenticated user. * * @var \Illuminate\Contracts\Auth\Authenticatable */ public $user; /** * The recovery code. * * @var string */ public $code; /** * Create a new event instance. * * @param \Illuminate\Contracts\Auth\Authenticatable $user * @param string $code * @return void */ public function __construct($user, $code) { $this->user = $user; $this->code = $code; } } src/Events/TwoFactorAuthenticationEnabled.php 0000755 00000000177 00000000000 0015344 0 ustar 00 <?php namespace Laravel\Fortify\Events; class TwoFactorAuthenticationEnabled extends TwoFactorAuthenticationEvent { // } src/Events/PasswordUpdatedViaController.php 0000755 00000000677 00000000000 0015103 0 ustar 00 <?php namespace Laravel\Fortify\Events; use Illuminate\Foundation\Events\Dispatchable; class PasswordUpdatedViaController { use Dispatchable; /** * The user instance. * * @var \App\Models\User */ public $user; /** * Create a new event instance. * * @param \App\Models\User $user * @return void */ public function __construct($user) { $this->user = $user; } } src/Events/TwoFactorAuthenticationChallenged.php 0000755 00000000202 00000000000 0016025 0 ustar 00 <?php namespace Laravel\Fortify\Events; class TwoFactorAuthenticationChallenged extends TwoFactorAuthenticationEvent { // } src/Actions/ConfirmTwoFactorAuthentication.php 0000755 00000002677 00000000000 0015552 0 ustar 00 <?php namespace Laravel\Fortify\Actions; use Illuminate\Validation\ValidationException; use Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider; use Laravel\Fortify\Events\TwoFactorAuthenticationConfirmed; class ConfirmTwoFactorAuthentication { /** * The two factor authentication provider. * * @var \Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider */ protected $provider; /** * Create a new action instance. * * @param \Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider $provider * @return void */ public function __construct(TwoFactorAuthenticationProvider $provider) { $this->provider = $provider; } /** * Confirm the two factor authentication configuration for the user. * * @param mixed $user * @param string $code * @return void */ public function __invoke($user, $code) { if (empty($user->two_factor_secret) || empty($code) || ! $this->provider->verify(decrypt($user->two_factor_secret), $code)) { throw ValidationException::withMessages([ 'code' => [__('The provided two factor authentication code was invalid.')], ])->errorBag('confirmTwoFactorAuthentication'); } $user->forceFill([ 'two_factor_confirmed_at' => now(), ])->save(); TwoFactorAuthenticationConfirmed::dispatch($user); } } src/Actions/PrepareAuthenticatedSession.php 0000755 00000001566 00000000000 0015065 0 ustar 00 <?php namespace Laravel\Fortify\Actions; use Laravel\Fortify\LoginRateLimiter; class PrepareAuthenticatedSession { /** * The login rate limiter instance. * * @var \Laravel\Fortify\LoginRateLimiter */ protected $limiter; /** * Create a new class instance. * * @param \Laravel\Fortify\LoginRateLimiter $limiter * @return void */ public function __construct(LoginRateLimiter $limiter) { $this->limiter = $limiter; } /** * Handle the incoming request. * * @param \Illuminate\Http\Request $request * @param callable $next * @return mixed */ public function handle($request, $next) { if ($request->hasSession()) { $request->session()->regenerate(); } $this->limiter->clear($request); return $next($request); } } src/Actions/CanonicalizeUsername.php 0000755 00000000764 00000000000 0013516 0 ustar 00 <?php namespace Laravel\Fortify\Actions; use Illuminate\Support\Str; use Laravel\Fortify\Fortify; class CanonicalizeUsername { /** * Handle the incoming request. * * @param \Illuminate\Http\Request $request * @param callable $next * @return mixed */ public function handle($request, $next) { $request->merge([ Fortify::username() => Str::lower($request->{Fortify::username()}), ]); return $next($request); } } src/Actions/DisableTwoFactorAuthentication.php 0000755 00000001536 00000000000 0015511 0 ustar 00 <?php namespace Laravel\Fortify\Actions; use Laravel\Fortify\Events\TwoFactorAuthenticationDisabled; use Laravel\Fortify\Fortify; class DisableTwoFactorAuthentication { /** * Disable two factor authentication for the user. * * @param mixed $user * @return void */ public function __invoke($user) { if (! is_null($user->two_factor_secret) || ! is_null($user->two_factor_recovery_codes) || ! is_null($user->two_factor_confirmed_at)) { $user->forceFill([ 'two_factor_secret' => null, 'two_factor_recovery_codes' => null, ] + (Fortify::confirmsTwoFactorAuthentication() ? [ 'two_factor_confirmed_at' => null, ] : []))->save(); TwoFactorAuthenticationDisabled::dispatch($user); } } } src/Actions/EnsureLoginIsNotThrottled.php 0000755 00000001732 00000000000 0014514 0 ustar 00 <?php namespace Laravel\Fortify\Actions; use Illuminate\Auth\Events\Lockout; use Laravel\Fortify\Contracts\LockoutResponse; use Laravel\Fortify\LoginRateLimiter; class EnsureLoginIsNotThrottled { /** * The login rate limiter instance. * * @var \Laravel\Fortify\LoginRateLimiter */ protected $limiter; /** * Create a new class instance. * * @param \Laravel\Fortify\LoginRateLimiter $limiter * @return void */ public function __construct(LoginRateLimiter $limiter) { $this->limiter = $limiter; } /** * Handle the incoming request. * * @param \Illuminate\Http\Request $request * @param callable $next * @return mixed */ public function handle($request, $next) { if (! $this->limiter->tooManyAttempts($request)) { return $next($request); } event(new Lockout($request)); return app(LockoutResponse::class); } } src/Actions/RedirectIfTwoFactorAuthenticatable.php 0000755 00000011105 00000000000 0016275 0 ustar 00 <?php namespace Laravel\Fortify\Actions; use Illuminate\Auth\Events\Failed; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Validation\ValidationException; use Laravel\Fortify\Events\TwoFactorAuthenticationChallenged; use Laravel\Fortify\Fortify; use Laravel\Fortify\LoginRateLimiter; use Laravel\Fortify\TwoFactorAuthenticatable; class RedirectIfTwoFactorAuthenticatable { /** * The guard implementation. * * @var \Illuminate\Contracts\Auth\StatefulGuard */ protected $guard; /** * The login rate limiter instance. * * @var \Laravel\Fortify\LoginRateLimiter */ protected $limiter; /** * Create a new controller instance. * * @param \Illuminate\Contracts\Auth\StatefulGuard $guard * @param \Laravel\Fortify\LoginRateLimiter $limiter * @return void */ public function __construct(StatefulGuard $guard, LoginRateLimiter $limiter) { $this->guard = $guard; $this->limiter = $limiter; } /** * Handle the incoming request. * * @param \Illuminate\Http\Request $request * @param callable $next * @return mixed */ public function handle($request, $next) { $user = $this->validateCredentials($request); if (Fortify::confirmsTwoFactorAuthentication()) { if (optional($user)->two_factor_secret && ! is_null(optional($user)->two_factor_confirmed_at) && in_array(TwoFactorAuthenticatable::class, class_uses_recursive($user))) { return $this->twoFactorChallengeResponse($request, $user); } else { return $next($request); } } if (optional($user)->two_factor_secret && in_array(TwoFactorAuthenticatable::class, class_uses_recursive($user))) { return $this->twoFactorChallengeResponse($request, $user); } return $next($request); } /** * Attempt to validate the incoming credentials. * * @param \Illuminate\Http\Request $request * @return mixed */ protected function validateCredentials($request) { if (Fortify::$authenticateUsingCallback) { return tap(call_user_func(Fortify::$authenticateUsingCallback, $request), function ($user) use ($request) { if (! $user) { $this->fireFailedEvent($request); $this->throwFailedAuthenticationException($request); } }); } $model = $this->guard->getProvider()->getModel(); return tap($model::where(Fortify::username(), $request->{Fortify::username()})->first(), function ($user) use ($request) { if (! $user || ! $this->guard->getProvider()->validateCredentials($user, ['password' => $request->password])) { $this->fireFailedEvent($request, $user); $this->throwFailedAuthenticationException($request); } }); } /** * Throw a failed authentication validation exception. * * @param \Illuminate\Http\Request $request * @return void * * @throws \Illuminate\Validation\ValidationException */ protected function throwFailedAuthenticationException($request) { $this->limiter->increment($request); throw ValidationException::withMessages([ Fortify::username() => [trans('auth.failed')], ]); } /** * Fire the failed authentication attempt event with the given arguments. * * @param \Illuminate\Http\Request $request * @param \Illuminate\Contracts\Auth\Authenticatable|null $user * @return void */ protected function fireFailedEvent($request, $user = null) { event(new Failed(config('fortify.guard'), $user, [ Fortify::username() => $request->{Fortify::username()}, 'password' => $request->password, ])); } /** * Get the two factor authentication enabled response. * * @param \Illuminate\Http\Request $request * @param mixed $user * @return \Symfony\Component\HttpFoundation\Response */ protected function twoFactorChallengeResponse($request, $user) { $request->session()->put([ 'login.id' => $user->getKey(), 'login.remember' => $request->boolean('remember'), ]); TwoFactorAuthenticationChallenged::dispatch($user); return $request->wantsJson() ? response()->json(['two_factor' => true]) : redirect()->route('two-factor.login'); } } src/Actions/AttemptToAuthenticate.php 0000755 00000005653 00000000000 0013701 0 ustar 00 <?php namespace Laravel\Fortify\Actions; use Illuminate\Auth\Events\Failed; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Validation\ValidationException; use Laravel\Fortify\Fortify; use Laravel\Fortify\LoginRateLimiter; class AttemptToAuthenticate { /** * The guard implementation. * * @var \Illuminate\Contracts\Auth\StatefulGuard */ protected $guard; /** * The login rate limiter instance. * * @var \Laravel\Fortify\LoginRateLimiter */ protected $limiter; /** * Create a new controller instance. * * @param \Illuminate\Contracts\Auth\StatefulGuard $guard * @param \Laravel\Fortify\LoginRateLimiter $limiter * @return void */ public function __construct(StatefulGuard $guard, LoginRateLimiter $limiter) { $this->guard = $guard; $this->limiter = $limiter; } /** * Handle the incoming request. * * @param \Illuminate\Http\Request $request * @param callable $next * @return mixed */ public function handle($request, $next) { if (Fortify::$authenticateUsingCallback) { return $this->handleUsingCustomCallback($request, $next); } if ($this->guard->attempt( $request->only(Fortify::username(), 'password'), $request->boolean('remember')) ) { return $next($request); } $this->throwFailedAuthenticationException($request); } /** * Attempt to authenticate using a custom callback. * * @param \Illuminate\Http\Request $request * @param callable $next * @return mixed */ protected function handleUsingCustomCallback($request, $next) { $user = call_user_func(Fortify::$authenticateUsingCallback, $request); if (! $user) { $this->fireFailedEvent($request); return $this->throwFailedAuthenticationException($request); } $this->guard->login($user, $request->boolean('remember')); return $next($request); } /** * Throw a failed authentication validation exception. * * @param \Illuminate\Http\Request $request * @return void * * @throws \Illuminate\Validation\ValidationException */ protected function throwFailedAuthenticationException($request) { $this->limiter->increment($request); throw ValidationException::withMessages([ Fortify::username() => [trans('auth.failed')], ]); } /** * Fire the failed authentication attempt event with the given arguments. * * @param \Illuminate\Http\Request $request * @return void */ protected function fireFailedEvent($request) { event(new Failed(config('fortify.guard'), null, [ Fortify::username() => $request->{Fortify::username()}, 'password' => $request->password, ])); } } src/Actions/ConfirmPassword.php 0000755 00000002225 00000000000 0012531 0 ustar 00 <?php namespace Laravel\Fortify\Actions; use Illuminate\Contracts\Auth\StatefulGuard; use Laravel\Fortify\Fortify; class ConfirmPassword { /** * Confirm that the given password is valid for the given user. * * @param \Illuminate\Contracts\Auth\StatefulGuard $guard * @param mixed $user * @param string|null $password * @return bool */ public function __invoke(StatefulGuard $guard, $user, ?string $password = null) { $username = Fortify::username(); return is_null(Fortify::$confirmPasswordsUsingCallback) ? $guard->validate([ $username => $user->{$username}, 'password' => $password, ]) : $this->confirmPasswordUsingCustomCallback($user, $password); } /** * Confirm the user's password using a custom callback. * * @param mixed $user * @param string|null $password * @return bool */ protected function confirmPasswordUsingCustomCallback($user, ?string $password = null) { return call_user_func( Fortify::$confirmPasswordsUsingCallback, $user, $password ); } } src/Actions/EnableTwoFactorAuthentication.php 0000755 00000002604 00000000000 0015331 0 ustar 00 <?php namespace Laravel\Fortify\Actions; use Illuminate\Support\Collection; use Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider; use Laravel\Fortify\Events\TwoFactorAuthenticationEnabled; use Laravel\Fortify\RecoveryCode; class EnableTwoFactorAuthentication { /** * The two factor authentication provider. * * @var \Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider */ protected $provider; /** * Create a new action instance. * * @param \Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider $provider * @return void */ public function __construct(TwoFactorAuthenticationProvider $provider) { $this->provider = $provider; } /** * Enable two factor authentication for the user. * * @param mixed $user * @param bool $force * @return void */ public function __invoke($user, $force = false) { if (empty($user->two_factor_secret) || $force === true) { $user->forceFill([ 'two_factor_secret' => encrypt($this->provider->generateSecretKey()), 'two_factor_recovery_codes' => encrypt(json_encode(Collection::times(8, function () { return RecoveryCode::generate(); })->all())), ])->save(); TwoFactorAuthenticationEnabled::dispatch($user); } } } src/Actions/GenerateNewRecoveryCodes.php 0000755 00000001174 00000000000 0014314 0 ustar 00 <?php namespace Laravel\Fortify\Actions; use Illuminate\Support\Collection; use Laravel\Fortify\Events\RecoveryCodesGenerated; use Laravel\Fortify\RecoveryCode; class GenerateNewRecoveryCodes { /** * Generate new recovery codes for the user. * * @param mixed $user * @return void */ public function __invoke($user) { $user->forceFill([ 'two_factor_recovery_codes' => encrypt(json_encode(Collection::times(8, function () { return RecoveryCode::generate(); })->all())), ])->save(); RecoveryCodesGenerated::dispatch($user); } } src/Actions/CompletePasswordReset.php 0000755 00000001077 00000000000 0013713 0 ustar 00 <?php namespace Laravel\Fortify\Actions; use Illuminate\Auth\Events\PasswordReset; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Support\Str; class CompletePasswordReset { /** * Complete the password reset process for the given user. * * @param \Illuminate\Contracts\Auth\StatefulGuard $guard * @param mixed $user * @return void */ public function __invoke(StatefulGuard $guard, $user) { $user->setRememberToken(Str::random(60)); $user->save(); event(new PasswordReset($user)); } } composer.json 0000755 00000003351 00000000000 0007234 0 ustar 00 { "name": "laravel/fortify", "description": "Backend controllers and scaffolding for Laravel authentication.", "keywords": ["laravel", "auth"], "license": "MIT", "support": { "issues": "https://github.com/laravel/fortify/issues", "source": "https://github.com/laravel/fortify" }, "authors": [ { "name": "Taylor Otwell", "email": "taylor@laravel.com" } ], "require": { "php": "^8.1", "ext-json": "*", "bacon/bacon-qr-code": "^2.0", "illuminate/support": "^10.0|^11.0", "symfony/console": "^6.0|^7.0", "pragmarx/google2fa": "^8.0" }, "require-dev": { "mockery/mockery": "^1.0", "orchestra/testbench": "^8.16|^9.0", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^10.4" }, "autoload": { "psr-4": { "Laravel\\Fortify\\": "src/" } }, "autoload-dev": { "psr-4": { "Laravel\\Fortify\\Tests\\": "tests/", "App\\": "workbench/app/", "Database\\Factories\\": "workbench/database/factories/" }, "classmap": ["stubs/"] }, "extra": { "branch-alias": { "dev-master": "1.x-dev" }, "laravel": { "providers": [ "Laravel\\Fortify\\FortifyServiceProvider" ] } }, "config": { "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { "post-autoload-dump": "@prepare", "prepare": "@php vendor/bin/testbench package:discover --ansi", "lint": "@php vendor/bin/phpstan analyse", "test": "@php vendor/bin/phpunit" } } stubs/ResetUserPassword.php 0000755 00000001265 00000000000 0012031 0 ustar 00 <?php namespace App\Actions\Fortify; use App\Models\User; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Laravel\Fortify\Contracts\ResetsUserPasswords; class ResetUserPassword implements ResetsUserPasswords { use PasswordValidationRules; /** * Validate and reset the user's forgotten password. * * @param array<string, string> $input */ public function reset(User $user, array $input): void { Validator::make($input, [ 'password' => $this->passwordRules(), ])->validate(); $user->forceFill([ 'password' => Hash::make($input['password']), ])->save(); } } stubs/CreateNewUser.php 0000755 00000001770 00000000000 0011102 0 ustar 00 <?php namespace App\Actions\Fortify; use App\Models\User; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; use Laravel\Fortify\Contracts\CreatesNewUsers; class CreateNewUser implements CreatesNewUsers { use PasswordValidationRules; /** * Validate and create a newly registered user. * * @param array<string, string> $input */ public function create(array $input): User { Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], 'email' => [ 'required', 'string', 'email', 'max:255', Rule::unique(User::class), ], 'password' => $this->passwordRules(), ])->validate(); return User::create([ 'name' => $input['name'], 'email' => $input['email'], 'password' => Hash::make($input['password']), ]); } } stubs/FortifyServiceProvider.php 0000755 00000002575 00000000000 0013050 0 ustar 00 <?php namespace App\Providers; use App\Actions\Fortify\CreateNewUser; use App\Actions\Fortify\ResetUserPassword; use App\Actions\Fortify\UpdateUserPassword; use App\Actions\Fortify\UpdateUserProfileInformation; use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Http\Request; use Illuminate\Support\Facades\RateLimiter; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Str; use Laravel\Fortify\Fortify; class FortifyServiceProvider extends ServiceProvider { /** * Register any application services. */ public function register(): void { // } /** * Bootstrap any application services. */ public function boot(): void { Fortify::createUsersUsing(CreateNewUser::class); Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class); Fortify::updateUserPasswordsUsing(UpdateUserPassword::class); Fortify::resetUserPasswordsUsing(ResetUserPassword::class); RateLimiter::for('login', function (Request $request) { $throttleKey = Str::transliterate(Str::lower($request->input(Fortify::username())).'|'.$request->ip()); return Limit::perMinute(5)->by($throttleKey); }); RateLimiter::for('two-factor', function (Request $request) { return Limit::perMinute(5)->by($request->session()->get('login.id')); }); } } stubs/PasswordValidationRules.php 0000755 00000000637 00000000000 0013217 0 ustar 00 <?php namespace App\Actions\Fortify; use Illuminate\Validation\Rules\Password; trait PasswordValidationRules { /** * Get the validation rules used to validate passwords. * * @return array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string> */ protected function passwordRules(): array { return ['required', 'string', Password::default(), 'confirmed']; } } stubs/UpdateUserPassword.php 0000755 00000001634 00000000000 0012171 0 ustar 00 <?php namespace App\Actions\Fortify; use App\Models\User; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Laravel\Fortify\Contracts\UpdatesUserPasswords; class UpdateUserPassword implements UpdatesUserPasswords { use PasswordValidationRules; /** * Validate and update the user's password. * * @param array<string, string> $input */ public function update(User $user, array $input): void { Validator::make($input, [ 'current_password' => ['required', 'string', 'current_password:web'], 'password' => $this->passwordRules(), ], [ 'current_password.current_password' => __('The provided password does not match your current password.'), ])->validateWithBag('updatePassword'); $user->forceFill([ 'password' => Hash::make($input['password']), ])->save(); } } stubs/UpdateUserProfileInformation.php 0000755 00000003142 00000000000 0014171 0 ustar 00 <?php namespace App\Actions\Fortify; use App\Models\User; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; use Laravel\Fortify\Contracts\UpdatesUserProfileInformation; class UpdateUserProfileInformation implements UpdatesUserProfileInformation { /** * Validate and update the given user's profile information. * * @param array<string, string> $input */ public function update(User $user, array $input): void { Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], 'email' => [ 'required', 'string', 'email', 'max:255', Rule::unique('users')->ignore($user->id), ], ])->validateWithBag('updateProfileInformation'); if ($input['email'] !== $user->email && $user instanceof MustVerifyEmail) { $this->updateVerifiedUser($user, $input); } else { $user->forceFill([ 'name' => $input['name'], 'email' => $input['email'], ])->save(); } } /** * Update the given verified user's profile information. * * @param array<string, string> $input */ protected function updateVerifiedUser(User $user, array $input): void { $user->forceFill([ 'name' => $input['name'], 'email' => $input['email'], 'email_verified_at' => null, ])->save(); $user->sendEmailVerificationNotification(); } } stubs/fortify.php 0000755 00000012374 00000000000 0010052 0 ustar 00 <?php use Laravel\Fortify\Features; return [ /* |-------------------------------------------------------------------------- | Fortify Guard |-------------------------------------------------------------------------- | | Here you may specify which authentication guard Fortify will use while | authenticating users. This value should correspond with one of your | guards that is already present in your "auth" configuration file. | */ 'guard' => 'web', /* |-------------------------------------------------------------------------- | Fortify Password Broker |-------------------------------------------------------------------------- | | Here you may specify which password broker Fortify can use when a user | is resetting their password. This configured value should match one | of your password brokers setup in your "auth" configuration file. | */ 'passwords' => 'users', /* |-------------------------------------------------------------------------- | Username / Email |-------------------------------------------------------------------------- | | This value defines which model attribute should be considered as your | application's "username" field. Typically, this might be the email | address of the users but you are free to change this value here. | | Out of the box, Fortify expects forgot password and reset password | requests to have a field named 'email'. If the application uses | another name for the field you may define it below as needed. | */ 'username' => 'email', 'email' => 'email', /* |-------------------------------------------------------------------------- | Lowercase Usernames |-------------------------------------------------------------------------- | | This value defines whether usernames should be lowercased before saving | them in the database, as some database system string fields are case | sensitive. You may disable this for your application if necessary. | */ 'lowercase_usernames' => true, /* |-------------------------------------------------------------------------- | Home Path |-------------------------------------------------------------------------- | | Here you may configure the path where users will get redirected during | authentication or password reset when the operations are successful | and the user is authenticated. You are free to change this value. | */ 'home' => '/home', /* |-------------------------------------------------------------------------- | Fortify Routes Prefix / Subdomain |-------------------------------------------------------------------------- | | Here you may specify which prefix Fortify will assign to all the routes | that it registers with the application. If necessary, you may change | subdomain under which all of the Fortify routes will be available. | */ 'prefix' => '', 'domain' => null, /* |-------------------------------------------------------------------------- | Fortify Routes Middleware |-------------------------------------------------------------------------- | | Here you may specify which middleware Fortify will assign to the routes | that it registers with the application. If necessary, you may change | these middleware but typically this provided default is preferred. | */ 'middleware' => ['web'], /* |-------------------------------------------------------------------------- | Rate Limiting |-------------------------------------------------------------------------- | | By default, Fortify will throttle logins to five requests per minute for | every email and IP address combination. However, if you would like to | specify a custom rate limiter to call then you may specify it here. | */ 'limiters' => [ 'login' => 'login', 'two-factor' => 'two-factor', ], /* |-------------------------------------------------------------------------- | Register View Routes |-------------------------------------------------------------------------- | | Here you may specify if the routes returning views should be disabled as | you may not need them when building your own application. This may be | especially true if you're writing a custom single-page application. | */ 'views' => true, /* |-------------------------------------------------------------------------- | Features |-------------------------------------------------------------------------- | | Some of the Fortify features are optional. You may disable the features | by removing them from this array. You're free to only remove some of | these features or you can even remove all of these if you need to. | */ 'features' => [ Features::registration(), Features::resetPasswords(), // Features::emailVerification(), Features::updateProfileInformation(), Features::updatePasswords(), Features::twoFactorAuthentication([ 'confirm' => true, 'confirmPassword' => true, // 'window' => 0, ]), ], ];
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings