composer require laravel/fortify
This will creatre a slew of files
php artisan vendor:publish --provider="Laravel\Fortify\FortifyServiceProvider"
INFO Publishing assets.
Copying file [vendor/laravel/fortify/stubs/fortify.php] to [config/fortify.php] ............................................................. DONE
Copying file [vendor/laravel/fortify/stubs/CreateNewUser.php] to [app/Actions/Fortify/CreateNewUser.php] .................................... DONE
Copying file [vendor/laravel/fortify/stubs/FortifyServiceProvider.php] to [app/Providers/FortifyServiceProvider.php] ........................ DONE
Copying file [vendor/laravel/fortify/stubs/PasswordValidationRules.php] to [app/Actions/Fortify/PasswordValidationRules.php] ................ DONE
Copying file [vendor/laravel/fortify/stubs/ResetUserPassword.php] to [app/Actions/Fortify/ResetUserPassword.php] ............................ DONE
Copying file [vendor/laravel/fortify/stubs/UpdateUserProfileInformation.php] to [app/Actions/Fortify/UpdateUserProfileInformation.php] ...... DONE
Copying file [vendor/laravel/fortify/stubs/UpdateUserPassword.php] to [app/Actions/Fortify/UpdateUserPassword.php] .......................... DONE
Copying directory [vendor/laravel/fortify/database/migrations] to [database/migrations] ..................................................... DONE
php artisan migrate
INFO Running migrations.
2014_10_12_200000_add_two_factor_columns_to_users_table ................................................................................ 73ms DONE
This will creatre a number of various GET and POST routes
php artisan route:list --method=GET
GET|HEAD forgot-password .................................................................................................................................................................................................................. password.request › Laravel\Fortify › PasswordResetLinkController@create
GET|HEAD login .................................................................................................................................................................................................................................... login › Laravel\Fortify › AuthenticatedSessionController@create
GET|HEAD register .................................................................................................................................................................................................................................... register › Laravel\Fortify › RegisteredUserController@create
GET|HEAD reset-password/{token} ................................................................................................................................................................................................................... password.reset › Laravel\Fortify › NewPasswordController@create
GET|HEAD two-factor-challenge ................................................................................................................................................................................................. two-factor.login › Laravel\Fortify › TwoFactorAuthenticatedSessionController@create
GET|HEAD user/confirm-password ............................................................................................................................................................................................................................... Laravel\Fortify › ConfirmablePasswordController@show
GET|HEAD user/confirmed-password-status .......................................................................................................................................................................................... password.confirmation › Laravel\Fortify › ConfirmedPasswordStatusController@show
GET|HEAD user/two-factor-qr-code ............................................................................................................................................................................................................ two-factor.qr-code › Laravel\Fortify › TwoFactorQrCodeController@show
GET|HEAD user/two-factor-recovery-codes ................................................................................................................................................................................................ two-factor.recovery-codes › Laravel\Fortify › RecoveryCodeController@index
GET|HEAD user/two-factor-secret-key ................................................................................................................................................................................................... two-factor.secret-key › Laravel\Fortify › TwoFactorSecretKeyController@show
You can turn these features off in /config/fortify.php
Just comment out in these section
'features' => [
Features::registration(),
Features::resetPasswords(),
// Features::emailVerification(),
Features::updateProfileInformation(),
Features::updatePasswords(),
// Features::twoFactorAuthentication([
// 'confirm' => true,
// 'confirmPassword' => true,
// 'window' => 0,
// ]),
],
Now we haved turned off two factor in Fortify
$ php artisan route:list --method=GET
GET|HEAD / ........................................................................................................................................................................................................................................................................................................
GET|HEAD _ignition/health-check ............................................................................................................................................................................................................. ignition.healthCheck › Spatie\LaravelIgnition › HealthCheckController
GET|HEAD api/user .................................................................................................................................................................................................................................................................................................
GET|HEAD forgot-password .................................................................................................................................................................................................................. password.request › Laravel\Fortify › PasswordResetLinkController@create
GET|HEAD login .................................................................................................................................................................................................................................... login › Laravel\Fortify › AuthenticatedSessionController@create
GET|HEAD register .................................................................................................................................................................................................................................... register › Laravel\Fortify › RegisteredUserController@create
GET|HEAD reset-password/{token} ................................................................................................................................................................................................................... password.reset › Laravel\Fortify › NewPasswordController@create
GET|HEAD sanctum/csrf-cookie .................................................................................................................................................................................................................... sanctum.csrf-cookie › Laravel\Sanctum › CsrfCookieController@show
GET|HEAD user/confirm-password ............................................................................................................................................................................................................................... Laravel\Fortify › ConfirmablePasswordController@show
GET|HEAD user/confirmed-password-status .......................................................................................................................................................................................... password.confirmation › Laravel\Fortify › ConfirmedPasswordStatusController@show
Register app\Providers\FortifyServiceProvider
classin the providers
array of your application's config/app.php
configuration file.
'providers' => [
/*
* Package Service Providers...
*/
App\Providers\FortifyServiceProvider::class,
],
probalby will need to run php artisan optimize
You will need to make views for each of these that you want to use
You need to be declare the view and make the views in the resource directory
You declare the views by adding to the boot() method in app/Providers/FortifyServiceProvider.php
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) {
$email = (string) $request->email;
return Limit::perMinute(5)->by($email . $request->ip());
});
RateLimiter::for('two-factor', function (Request $request) {
return Limit::perMinute(5)->by($request->session()->get('login.id'));
});
Fortify::loginView(function () {
return view('auth.login');
});
Fortify::registerView(function () {
return view('auth.register');
});
Fortify::requestPasswordResetLinkView(function () {
return view('auth.forgot-password');
});
Fortify::resetPasswordView(function ($request) {
return view('auth.reset-password', ['request' => $request]);
});
Fortify::verifyEmailView(function () {
return view('auth.verify-email');
});
}
Common error
Target [Laravel\Fortify\Contracts\RegisterViewResponse] is not instantiable.
Create 6 views
resources/views/auth/login.blade.php
resources/views/auth/register.blade.php
resources/views/auth/verify.blade.php
resources/views/auth/passwords/confirm.blade.php
resources/views/auth/passwords/email.blade.php
resources/views/auth/passwords/reset.blade.php
resources/views/home.blade.php
- Log in to post comments