Laravel Forti-Fantastic! ๐ŸŽ‰๐Ÿฐ

Funny Laravel docs · Warning: May cause actual learning AND laughter!

Browse funny laravel docs
On this page

Welcome to the Magic Kingdom of Authentication! ๐Ÿ‘จโ€๐Ÿ”ฌ๐Ÿš€

So, whatโ€™s this Fortify thing all about? ๐Ÿค”๐Ÿฆ„

Fortify is your magical toolkit for handling authentication and security in Laravel like a pro, without having to dabble in dark sorcery or bewitching incantations. Itโ€™s the perfect blend of power and ease, just like a well-crafted cocktail ๐Ÿธโœจ

When should I use Fortify? ๐Ÿ•ฐ๏ธ๐Ÿ‘จโ€๐Ÿ’ผ

Well, if you want to make your Laravel application more secure than a fortress made of cheese (yes, thatโ€™s a thing), then Fortify is the spell you need! Itโ€™s great for handling user registration, authentication, password resets, email verification, and two-factor authentication with a wave of your wand.

Installation ๐Ÿ“ฆ๐Ÿ› ๏ธ

Fortify Features ๐Ÿ’Žโœจ

Get ready to enchant your app with features like:

  1. Out-of-the-box two-factor authentication
  2. Secure password reset links
  3. Email verification
  4. Customizable redirects and more!

Disabling Views ๐Ÿ“บ๐Ÿ”’

If you prefer to keep your views under lock and key, Fortify lets you do that too! Just cast the right spell and enjoy a clean backend without any pesky distractions ๐Ÿงน๐Ÿ‘ป

Authentication ๐Ÿ›ก๏ธ๐Ÿ”‘

Customizing User Authentication ๐Ÿฆพ๐ŸŽจ

Fortify lets you customize the authentication process to match your unique application style. From designing a one-of-a-kind login page to choosing the perfect error messages, itโ€™s all in your hands!

Customizing the Authentication Pipeline ๐Ÿ•ฐ๏ธ๐Ÿ”„

Want to tweak the way user authentication works? Fortify allows you to customize the authentication pipeline, giving you the power to add extra security measures or perform additional tasks as needed. Itโ€™s like being able to summon a dragon at will!

Customizing Authentication Redirects ๐ŸŽข๐Ÿ›ซ

Want to send users to different destinations after they log in? Fortify makes it easy to customize authentication redirects, so you can guide your users on a magical journey through your application.

Two-Factor Authentication ๐Ÿ”’๐Ÿ”“

Enabling Two-Factor Authentication ๐Ÿฆพ๐Ÿ”‘

Add an extra layer of security to your app by enabling two-factor authentication with Fortify. Itโ€™s like adding a secret password to unlock the ultimate vault, and it will keep unauthorized users at bay!

Authenticating With Two-Factor Authentication ๐Ÿ•ต๏ธโ€โ™‚๏ธ๐Ÿ“ฑ

With two-factor authentication enabled, users will be required to enter a verification code in addition to their password. Fortify handles all the heavy lifting for you, making it easy to verify codes and keep your app secure.

Disabling Two-Factor Authentication ๐Ÿ”“๐Ÿ’”

If you ever need to disable two-factor authentication (perhaps because youโ€™ve decided to trust your users a little too much), Fortify makes it simple to do so without any fuss. Just remember, with great trust comes great responsibility!

Registration ๐Ÿง”๐Ÿ’ผ

Customizing Registration ๐Ÿ“๐ŸŽจ

Fortify lets you customize the registration process to make it fit seamlessly into your application. You can change the fields, validate user input, and even add custom logic for creating users. Itโ€™s like being able to conjure up users at will!

Password Reset ๐Ÿ”“๐Ÿ’”

If a user forgets their password, they can request a reset link using Fortifyโ€™s built-in feature. The system will securely generate and send the link to the userโ€™s email address, allowing them to regain access to their account without any hassle.

Resetting the Password ๐Ÿ”’๐Ÿ”“

Once users receive their password reset link, they can click on it to be taken to a page where they can enter a new password for their account. Fortify handles all the password validation and encryption for you, ensuring that user data remains secure.

Customizing Password Resets ๐ŸŽจ๐Ÿ“

If you want to add some extra flair or custom logic to the password reset process, Fortify allows you to do so. You can change the email templates, modify the password rules, and even add custom actions to the reset process. Itโ€™s like having a personal password wizard at your disposal!

Email Verification ๐Ÿ“ง๐Ÿ•ต๏ธโ€โ™‚๏ธ

Protecting Routes ๐Ÿ›ก๏ธ๐Ÿ”’

Fortify lets you protect specific routes within your application, ensuring that only verified users can access them. Itโ€™s like setting up a guard post to keep unverified users away!

Password Confirmation ๐Ÿ›ก๏ธ๐Ÿ”“

Ensuring Users Enter Their Correct Passwords ๐Ÿ•ต๏ธโ€โ™‚๏ธ๐Ÿ”“

Fortify includes a password confirmation feature to ensure that users enter their correct passwords when logging in. Itโ€™s like having a password-checking fairy at your side!

And there you have it, folks! Fortify is your one-stop shop for handling authentication and security in Laravel, making your app more secure than Fort Knox while keeping things easy to manage. So grab your wand and get ready to cast some magical spells with Fortify! ๐Ÿฆพโœจ๐Ÿš€

Meet Laravel Fortify, your new BFF in the backend world of Laravel! Think of it as the superhero sidekick who handles all the heavy lifting when it comes to authentication. No more capes, just code!

Fortify, unlike other sidekicks, isnโ€™t picky about frontends. It plays well with everyone - from Superman to Spiderman (or Angular to Vue, if you prefer). It sets up the routes and controllers needed for Laravelโ€™s full suite of authentication features: login, registration, password resets, email verifications, and more! Once installed, give it a warm welcome with the route:list Artisan command.

Since Fortify is a bit shy about its user interface, it prefers to hang out with your custom UI โ€“ you know, the cool kid on the block. Weโ€™ll dive deeper into how these two become best friends in the following sections of this documentation.

Note

While Fortify can be your wingman, remember that itโ€™s not mandatory. You can always opt to go solo and directly interact with Laravelโ€™s authentication services. For more details, check out the authentication, password reset, and email verification documentation. You go, glamourpuss!

Ah, the delightful world of Laravel Fortify! Itโ€™s a bit like having a butler for your applicationโ€™s backdoor shenanigans โ€“ without the monocle or the snobbish accent.

Fortify is an impeccable, frontend-agnostic authentication butler for your Laravel parties. It registers the routes and controllers needed to handle all of Laravelโ€™s authentication dances, including logins, registrations, password resets, email verifications, and more.

Now, hold onto your top hats, because here comes the twist โ€“ you donโ€™t have to be besties with Fortify to enjoy Laravelโ€™s authentication jamboree! You can always manually cut in on Laravelโ€™s authentication moves by following the dance steps outlined in the authentication, password reset, and email verification manuals.

If youโ€™re new to Laravel, consider Fortify as your wingman at the dance โ€“ or rather, your butler for authentication events. Dive into our application starter kits. These dapper kits use Fortify under the cuff to provide an elegant user interface, made with the sleek style of Tailwind CSS, for your applicationโ€™s authentication ballroom scenes. This way, you can practice and get cozy with Laravelโ€™s authentication moves without having to worry about stepping on anyoneโ€™s toes.

In essence, Fortify takes the routes and controllers from our application starter kits and offers them as a package devoid of a user interface โ€“ think of it as the black-tie version for your backend authentication needs. This allows you to quickly scaffold the backstage operations of your applicationโ€™s authentication layer without being confined to any particular frontend fashion faux pas.

When should one use Fortify, you ask? Well, if you prefer a well-dressed, dependable butler for your applicationโ€™s authentication events โ€“ rather than DIYing it with a feather boa and a top hat โ€“ then Fortify is the perfect dance partner for you!

Alrighty, mate! Letโ€™s dive into the world of Laravel Fortify โ€“ the authentication sidekick your application never knew it needed!

First off, if youโ€™re using one of Laravelโ€™s swanky application starter kits, then consider Fortify as the life of the party; itโ€™s already invited and ready to rock. No need for a separate RSVP!

Now, if youโ€™re going solo without a starter kit and your project needs to lock down its VIP area, youโ€™ve got two options: DIY or call in Fortify as backup. DIY might be fun, but it can also lead to awkward dance moves. Fortify, on the other hand, will bring the disco ball and the DJ booth!

If you decide to invite Fortify to the party, your user interface will start sending out requests to Fortifyโ€™s authentication routes, like a secret bouncer who handles all the authentication and registration duties without even breaking a sweat.

But if you fancy yourself as a bit of an authentification maestro and prefer to work directly with Laravelโ€™s authentication services, well then, suit yourself! You can follow the instructions in the authentication, password reset, and email verification documentation. Just remember, itโ€™s like learning to dance โ€“ practice makes perfect!

And letโ€™s not forget about the Laravel Sanctum! Itโ€™s a bit like the VIP guest list that Fortify checks before allowing access to your applicationโ€™s private areas. Learn more about their love-hate relationship in the Laravel Fortify and Laravel Sanctum section.

So, whether youโ€™re a control freak or just love a good dance partner, Fortifyโ€™s got your back when it comes to securing your application! Letโ€™s boogie down to a safe and secure night of coding! ๐Ÿ’ƒ๐Ÿผ๐Ÿ•บ๐Ÿผ

Ahoy there, code wranglers! Letโ€™s clear up the confusion like a powerful storm sweeping through your dev environment. You might have noticed two packages in Laravel that sound as if they were named by a medieval sorcerer: Laravel Sanctum and Laravel Fortify.

Fear not, for these packages are allies, not rivals! Each tackles a different but related issue in the realm of app security, so thereโ€™s no need to pick sides or engage in a heated feud between them.

Now, letโ€™s embark on a journey through the mystical land of Laravel Sanctum: it handles the management of API tokens and authentication for existing users โ€“ be it via session cookies or magical tokens (we kid, theyโ€™re just tokens). However, it doesnโ€™t provide any routes that perform user registration, password reset ceremonies, or summoning eldritch abominations (again, just kidding!).

On the other hand, Laravel Fortify steps in to save the day with user registration, password resets, and all manner of security-related incantations. If youโ€™re crafting your own authentication layer for an API or a single-page application โ€“ basically, any magical realm where users roam โ€“ then it wouldnโ€™t be uncommon to employ both Laravel Fortify (for user registration, password resets, etc.) and Laravel Sanctum (API token management, session authentication) in your enchanted quest for security.

Now that weโ€™ve settled the mystery of these two packages, let us move on to their installation process! But before you start waving your wand (or terminal), remember: in this kingdom called Laravel, there are no shortcuts โ€“ just a series of well-documented commands and a few lines of code.

Ready to set sail on this exciting adventure? Letโ€™s get started!

Alrighty then! Letโ€™s get this Fortify party started, shall we? ๐Ÿฅณ

First things first, grab your Laravel tuxedo and fire up the Composer. You know, itโ€™s like the fashion police of the coding world. ๐Ÿ•ต๏ธโ€โ™‚๏ธ

composer require laravel/fortify

Now that youโ€™ve got your badge of honor (the package), letโ€™s bring Fortify to life with a little Artisan magic:

php artisan fortify:install

This command is like an invite-only, secret handshake for Laravel developers. It publishes all the awesome Fortify action figures (yes, theyโ€™re actual figurines) to your app/Actions playground, creating it if itโ€™s still in its box. ๐Ÿฆธโ€โ™‚๏ธ

Moreover, it unleashes a flock of digital pixies that sprinkle the FortifyServiceProvider, configuration file, and all essential database migrations across your project.

But wait, thereโ€™s more! Donโ€™t forget to give your database a quick facelift (migration) for Fortify to fit in seamlessly:

php artisan migrate

Now that weโ€™ve got the formalities out of the way, you can sit back, relax, and let your digital army of superheroes secure your Laravel realm! ๐Ÿš€ ๐Ÿฆธโ€โ™€๏ธ ๐Ÿ›ก๏ธ

Fortify Fandango! ๐ŸŽ‰๐ŸŽฌ

Ah, the fortify config file - itโ€™s like the backstage pass to your Laravel appโ€™s most exclusive VIP area! The features configuration array here acts as a Spotify playlist curator for the backend routes Fortify deems fit to grace your application with. To keep things simple and stylish, we suggest you only invite these basic authentication features that make every Laravel event pop:

'features' => [
    Features::registration()->dressed_to_impress(), // Dapperly dressed for the registration shindig! ๐Ÿคต๐Ÿ‘—
    Features::resetPasswords()->ready_for_the_redo(), // All set to give passwords a second chance at life. ๐Ÿ”„๐Ÿ”
    Features::emailVerification()->verified_and_fabulous(), // Verified and fabulous, just like Cher after a wardrobe malfunction! ๐Ÿ’ƒ๐Ÿ”ฅ
],

Oh, and if you ever feel the need to dismantle these featured acts, weโ€™ve got you covered! Just follow these steps to remove any unwanted performances from your event. ๐ŸŽค๐ŸŽบ๐Ÿ’”

Unleashing the Javascript Beast! (Disabling Views)

Welcome, my brave coders and adventurers! Letโ€™s talk about a daring feat for those building single-page applications - taming the mighty Laravel Fortify views. By default, itโ€™s all about the screens: login, registration, you name it! But what if you donโ€™t need these routes? Well, thatโ€™s like asking a superhero to take a vacation! You can disable them completely with a single configuration change.

Now, grab your capes and letโ€™s dive into the configuration file - config/fortify.php. Here, youโ€™ll find the section that controls these pesky views:

'views' => false,

Set this to false, and those views will be toast! (Just kiddingโ€ฆ they wonโ€™t actually burn. Theyโ€™re just disabled.) Now, your JavaScript-driven single-page application can rule the roost without any pesky view distractions! ๐Ÿฆนโ€โ™‚๏ธ๐Ÿš€

Disabling Views and Password Resets (The Double Whammy)

Alright, now that youโ€™ve disabled views like a pro, letโ€™s take it up a notch! You can also disable password resets if you wish to keep users locked out of their accounts forever. (Kiddingโ€ฆ we donโ€™t want to be mean!) To do this, simply add the following line within your config/fortify.php:

'passwords' => false,

Set it to false, and your users will have to learn to love their forgotten passwords! But remember, itโ€™s always a good idea to provide alternative ways for them to retrieve their passwords if they ever need help. Good luck, and happy coding! ๐Ÿค–๐ŸŽ‰

Alrighty then! Letโ€™s dive into the nitty-gritty of disabling views and password resets in our Fortify fortress, shall we? ๐ŸŽ‰๐Ÿ”’

First off, if youโ€™re feeling rebellious and decide to throw Fortifyโ€™s swanky views out the window, you better have a solid plan for your own password reset features. Remember, the lone wolf doesnโ€™t hunt alone! ๐Ÿบ

When implementing your very own password-resetting antics, itโ€™s essential to define a route named password.reset. This is the responsible party that will display your applicationโ€™s โ€œReset Passwordโ€ view. Why, you ask? Well, because Laravelโ€™s Illuminate\Auth\Notifications\ResetPassword notification is a bit of a control freak and demands that password reset URLs are generated via this very route. ๐Ÿ˜‚๐Ÿคนโ€โ™‚๏ธ

Now, with the technical jargon out of the way, letโ€™s put on our cowboy hats (you know, for the Old West vibe) and ride off into the sunset to victory! ๐ŸŒ…๐ŸŽ โœจ

Alrighty then! Letโ€™s strap on our programming cowboy boots and dive headfirst into Fortify, Laravelโ€™s super-cool authentication sidekick. Remember, this fellaโ€™s all about the backend, so if youโ€™re hankering for a polished frontend implementation of Laravelโ€™s auth features, you might wanna round up an application starter kit.

Now, customizing your login page with Fortify is as easy as pie, but with more PHP and less sugar. The Laravel\Fortify\Fortify class is your trusty steed in this rodeo. Typically, youโ€™ll call it from the boot method of your applicationโ€™s App\Providers\FortifyServiceProvider class. Fortify will take care of corralling the wild horses that are your authentication routes and taming them to return your custom login view:

use Laravel\Fortify\Fortify;

/**
 * Bootstrap any application services.
 */
public function boot(): void
{
    Fortify::loginView(function () {
        return view('auth.login'); // Saddle up that auth.login template!
    });

    // ...
}

Your login wrangling form should be ready to ride out with a POST request, headed straight for /login. This trail expects a trusty steed named email / username, and a loyal sidekick password. The name of your email / username pardner should match the username value within the config/fortify.php configuration file. In addition, a boolean remember field can be tossed in the saddlebags to signal the userโ€™s desire for the โ€œremember meโ€ feature provided by Laravel.

If your login ride is successful, Fortify will redirect you to the URI youโ€™ve configured within your applicationโ€™s fortify configuration file. If it was an XHR request, a 200 HTTP response will be returned like a well-broken bronco.

If the rodeo doesnโ€™t go as planned, fret not! The user will find themselves back on that dusty old login screen, and the validation errors will be available to you via the trusty $errors Blade template variable. Or, in case of an XHR request, the validation errors will be returned like a lasso, wrapping them up with a 422 HTTP response.

Now, boot up that Fortify service provider and lasso yourself some secure authentication fun! Yeehaw!

Unleashing Your Inner Superhero with Fortify Authentication! ๐Ÿฆธโ€โ™‚๏ธ๐Ÿ”ฅ

Ready to become the master of your own authentication destiny? With Fortify, you can do just that! ๐ŸŽ‰

By default, our super-powered authentication system will swoop in and save the day by retrieving and validating users based on your appโ€™s configuration. But sometimes, you might want more control over how login credentials are verified and users are rescued from obscurity. Fear not, dear hero! Fortify has a solution for that too!

Meet the Fortify::authenticateUsing methodโ€”your new best friend in the quest for custom authentication! This magical method accepts a special super-secret closure (we know, it sounds like something out of a comic book!) that receives your incoming HTTP request. The mission of this secret agent is to validate the login credentials attached to the request and return the dashing user instance associated with them. If the mission fails or no user can be found, our hero will graciously return null or false. Usually, this method should take off from the boot method of your trusty FortifyServiceProvider.

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Laravel\Fortify\Fortify;

/**
 * Gear up for a thrilling adventure!
 */
public function boot(): void
{
    Fortify::authenticateUsing(function (Request $request) {
        // Our hero swoops in to save the day!
        $user = User::where('email', $request->email)->first();

        if ($user &&
            Hash::check($request->password, $user->password)) {
                // Success! The user is returned and our hero returns to base.
                return $user;
        }
    });

    // ... (Our hero continues the adventure)
}

Now, don your cape and leap tall buildings in a single bound with custom authentication control at your fingertips! ๐Ÿš€๐ŸŒ„๐Ÿฆธโ€โ™‚๏ธ

Ah, the Authentication Guard! Think of it as your bouncer at the hottest club in town (your Laravel app). You can customize this velvet rope wielder with a bit of configuration magic in your applicationโ€™s fortify file. But remember, just like you wouldnโ€™t let a chicken into Studio 54, your chosen guard should be an implementation of the prestigious Illuminate\Contracts\Auth\StatefulGuard.

Now, if youโ€™re running a Single Page Application (SPA) here, things get a little disco-ish. To authenticate like a boss, you need to pair up Laravel Fortify with the suave and sophisticated Laravel Sanctum. Imagine it like asking your bouncer to work in harmony with a doorman from another equally fabulous club! ๐Ÿ’ƒ๐Ÿ•บ

Laravel Sanctum - your new BFF for all things SPAs and authentication. ๐Ÿ’–๐Ÿ˜Žโœจ

Alrighty then! Laravel Fortify turns login requests into a dance party of classes, all choreographed through an invokable pipeline. If youโ€™re feeling fancy, you can create your own sequel of steps for these login shenanigans. Each class should waltz their way onto the stage with an __invoke method that accepts a cool Illuminate\Http\Request as its dance partner and a $next variable to keep the party going by inviting the next class in line for a spin.

To start your own production, you can use the Fortify::authenticateThrough method, which expects a closure that returns an array of classes to lead the dance. This is usually performed in the boot method of your App\Providers\FortifyServiceProvider class.

Hereโ€™s a peek at the default routine for inspiration as you create your own moves:

use Laravel\Fortify\Actions\AttemptToAuthenticate; // The grand finale!
use Laravel\Fortify\Actions\CanonicalizeUsername; // Make sure all usernames are spelled correctly, no typos allowed!
use Laravel\Fortify\Actions\EnsureLoginIsNotThrottled; // Check for throttling to keep things fair and square.
use Laravel\Fortify\Actions\PrepareAuthenticatedSession; // Prep the session for a successful login.
use Laravel\Fortify\Actions\RedirectIfTwoFactorAuthenticatable; // If Two-Factor Authentication is enabled, redirect accordingly.
use Laravel\Fortify\Features;
use Laravel\Fortify\Fortify;
use Illuminate\Http\Request;

Fortify::authenticateThrough(function (Request $request) {
    return array_filter([
            config('fortify.limiters.login') ? null : EnsureLoginIsNotThrottled::class, // If throttling isn't enabled, skip this step.
            config('fortify.lowercase_usernames') ? CanonicalizeUsername::class : null, // Enable lowercase usernames? Let's make it rain alphabets!
            Features::enabled(Features::twoFactorAuthentication()) ? RedirectIfTwoFactorAuthenticatable::class : null, // If Two-Factor Authentication is enabled, it's time to get tangled in the two-step.
            AttemptToAuthenticate::class, // Time for the grand finale! Let's dance our way to a successful login.
            PrepareAuthenticatedSession::class, // A successful login means it's time to prep the session for a fantastic after-party.
    ]);
});

So grab your dance partners and letโ€™s get this login party started! ๐Ÿ’ƒ๐Ÿฝ๐Ÿ•บ๐Ÿผ

Alright, buckle up, cyber-pioneers! Letโ€™s dive into the world of Fortifyโ€™s Authentication Throttling, where we keep those pesky bots and hacker squirrels at bay. By default, itโ€™s like having a bouncer at the digital door of your app, checking IDs (username-IP combos) before letting anyone in. But hey, who needs one bouncer when you can have an entire security squad? Thatโ€™s where customization comes in!

Fancy yourself as more of a throttle control freak than the average bear? Fortify hears ya! With its sleek configuration options, you can specify your very own rate limiter via the fortify.limiters.login setting. This option is nestled snugly within your applicationโ€™s config/fortify.php file - think of it as a secret passphrase to your appโ€™s secure settings room.

[!NOTE] Now, hereโ€™s the real party trick: throw in some two-factor authentication (2FA) and an external web application firewall (WAF), and youโ€™ve got yourself a veritable security trifecta thatโ€™ll keep your legit app users safer than a fortnightโ€™s supply of canned spam.

And if customizing the throttle redirects is more your speed, why not jump on board the Authentication Redirect Express? All aboard! (Ahem, youโ€™ll find details under ) ๐Ÿš‚

Rockinโ€™ Redirects and Rollinโ€™ Responses

Alrighty, buckle up as we dive into the whirlwind world of customizing redirects! (Imagine a dramatic movie soundtrack here) ๐ŸŽบ

When you successfully log in, Fortifyโ€™ll whisk you away to the URI specified via the home option deep within your applicationโ€™s fortify config file. If the login was an AJAX request (think magic tricks), itโ€™ll return a 200 response instead. After logging out, well, thereโ€™s no escaping - youโ€™ll be back at the olโ€™ home base, /.

But what if you want to unleash the power of advanced customization? Fear not, my friend! You can bind implementations of the swanky LoginResponse and the debonair LogoutResponse contracts into Laravelโ€™s Service Container. (Think of it like a posh, high-tech country club where only the coolest contracts hang out.)

This shindig usually happens within the register method of your applicationโ€™s App\Providers\FortifyServiceProvider class:

Use Laravel\Fortify\Contracts\LogoutResponse as Contract;

/**
 * Register any application services.
 */
public function register(): void
{
    $this->app->instance(Contract::class, new class implements Contract {
        public function toResponse($request)
        {
            return redirect('/'); // Redirect back to the starting point!
        }
    });
}

And there you have it! Youโ€™re now the maestro of redirects and the king of responses. Just remember, with great power comes great responsibility (and maybe a snazzy cape). ๐Ÿš€๐Ÿฆธโ€โ™‚๏ธ

Two-Steps-Ahead Authentication (2SA)

Welcome, cyber-safety aficionados! Fasten your seatbelts as we dive into the exciting world of 2SA, the security feature thatโ€™s got more digits than a calculus textbook. With this bad boy enabled, your users will need to provide not just their secret password, but also a magical six-digit numeric token. This token is generated using a Time-Based One-Time Password (TOTP), which sounds like something straight out of Harry Potterโ€™s world!

But where does one find such an enchanted number? Fear not! Just download any TOTP compatible mobile authentication app, like Google Authenticator. Itโ€™s as easy as downloading a free game and trying to figure out how to win it (you never do).

First things first: make sure your applicationโ€™s App\Models\User model is equipped with the Laravel\Fortify\TwoFactorAuthenticatable trait. Itโ€™s like giving your user model a superpower suit, but instead of fighting crime, it fights off cybercriminals!

<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Fortify\TwoFactorAuthenticatable;

class User extends Authenticatable
{
    use Notifiable, TwoFactorAuthenticatable;
}

Next up, we need to create a screen within your application that lets users manage their 2SA settings. Think of it as their very own secret lair, but instead of storing supervillain weapons, theyโ€™ll store security settings! This control center should allow them to activate and deactivate 2SA, as well as regenerate their 2SA recovery codes (just in case they lose their phone or start growing a supervillainous beard).

By default, the features array of the fortify configuration file tells Fortifyโ€™s 2SA settings to require password confirmation before any modifications. So if your application hasnโ€™t implemented Fortifyโ€™s password confirmation feature yet, itโ€™s time to suit up and get to work!

Alrighty, hereโ€™s your guide to turning on Laravelโ€™s Two-Step Bouncer, aka TSA for apps! ๐Ÿ›‚

First off, send a POST request to the swanky /user/two-factor-authentication endpoint, like you would ask your favorite barista for a double espresso. If all goes well, your user will be whisked back to their previous URL, and a secret session variable named two-factor-authentication-enabled will magically appear. You can sniff this out in your templates to display a triumphant success message, something like:

@if (session('status') === 'twosome-authenticator-activated')
    <div class="mb-4 font-medium text-sm">
        Alrighty then! Let's wrap up the two-step setup below. ๐Ÿ•บ
    </div>
@endif

But hold your horses! Just because weโ€™ve initiated the dance doesnโ€™t mean itโ€™s over โ€“ the user still needs to confirm their two-factor auth settings by providing a valid code, like youโ€™d have to show ID at a fancy party. That means your success message should politely remind them that theyโ€™re not quite done yet:

@if (session('status') == 'two-factor-authentication-enabled')
    <div class="mb-4 font-medium text-sm">
        Whoa there, partner! Two-step confirmation time! ๐Ÿ•บ
    </div>
@endif

Next up, itโ€™s time to unveil the two-factor auth QR code for your user to scan like a modern-day treasure map. If youโ€™re using Blade for your frontend, you can grab the QR code SVG using the twoFactorQrCodeSvg method on the user instance:

$request->user()->twoFactorQrCodeSvg();

If youโ€™re building a JavaScript-powered frontend, make an XHR GET request to the /user/two-factor-qr-code endpoint to fetch the userโ€™s two-factor auth QR code. This endpoint will serve up a JSON object with an svg key. ๐ŸŽ

Now that your user has scanned the QR code, they can confirm their two-factor auth settings by entering the provided code. After which, theyโ€™ll have earned their cybersecurity badge and can rest easy knowing theyโ€™ve leveled up their app security game! ๐Ÿ†๐ŸŽ‰

Ahoy there, aspiring coders! Letโ€™s dive into the thrilling world of Laravel Two-Factor Authentication, shall we?

First things first, you need to show your user a QR code for their two-factor authentication like itโ€™s a treasure map to buried digital gold. But we also want to provide a swashbuckling text input where they can enter the secret pirate code (or authentication code, if you prefer) to validate their setup. This magical code must sail its way to our Laravel ship via a trusty POST request, destined for the /user/confirmed-two-factor-authentication port manned by Fortify.

Should this voyage be successful, prepare yourself for a rousing cheer! The user will be directed back to their original coordinates, and the status session variable will be set to โ€œtwo-factor-authentication-confirmedโ€, triggering this jolly celebration:

@if (session('status') === 'two-factor-authentication-confirmed')
    <div class="mb-4 font-medium text-sm">
        Hoist the Jolly Roger! Two-factor authentication confirmed and enabled like a well-aimed cannonball!
    </div>
@endif

In case youโ€™ve been making your requests with XHR (the pirateโ€™s walkie-talkie), fear not, for a resounding 200 will be hoisted in response.

Now, grab yer compass and navigate to the next section, where weโ€™ll uncover the exciting process of Displaying Recovery Codes! Arrrr! ๐Ÿดโ€โ˜ ๏ธ

Alrighty, letโ€™s dive into the world of two-step verification fun times! If youโ€™re displaying your appโ€™s frontend with Blade (which, letโ€™s face it, is cooler than a cucumber in a snowstorm), you can access those delightful recovery codes like so:

(array) $request->user()->recoveryCodes()

Just imagine, with these codes, your users can authenticate even if theyโ€™ve misplaced their trusty mobile devices. Donโ€™t laugh too hard; it happens to the best of us!

Now, for those JavaScript whizzes out there building a frontend as lively as a one-legged chicken, you might wanna make an XHR GET request to the /user/two-factor-recovery-codes endpoint. This little endpoint will serve up a JSON array full of your userโ€™s recovery codes, ready for you to snack on!

But wait, thereโ€™s more! If you want to regenerate those recovery codes (perhaps because your user has developed a habit of losing things), your application can make a POST request to the same /user/two-factor-recovery-codes endpoint. Itโ€™s like pressing the reset button on a game console, but for security!

And thatโ€™s all folks! Now you know how to handle those recovery codes with style and grace. Keep up the good work, and remember: always be prepared for those unavoidable โ€œOh no, where did I put my phone again?โ€ moments.

Alrighty, buckle up for some cybersecurity chuckles! Letโ€™s dive into the world of Two-Factor Authentication (TFA), aka โ€œthat extra step that prevents your account from being hijacked by intergalactic cyber squirrels.โ€

During login, Fortify, our super-smart security guard, will kick things off by redirecting users to your applicationโ€™s TFA challenge screen. But, if your app is making an XHR (AJAX) login request, itโ€™ll return a JSON object with a two_factor boolean property, letting you know whether or not itโ€™s time for the TFA dance.

To get the TFA party started, we need to give Fortify some instructions on how to serve our custom TFA challenge view. This can be done by summoning the mighty Laravel\Fortify\Fortify classโ€™s various methods from within your applicationโ€™s App\Providers\FortifyServiceProvider class, specifically in its boot method:

use Laravel\Fortify\Fortify;

/**
 * Bootstrap any application services.
 */
public function boot(): void
{
    Fortify::twoFactorChallengeView(function () {
        return view('auth.two-factor-challenge'); // Yes, you can name your views after whatever tickles your fancy!
    });

    // ...
}

Once thatโ€™s done, Fortify will handle the creation of the /two-factor-challenge route and serve up our custom TFA challenge view. Your trusty two-factor-challenge template should include a form that sends a POST request to the /two-factor-challenge endpoint, complete with a code field for Time-based One-time Password (TOTP) tokens or a recovery_code field for those emergency situations when you left your phone at home.

If the login attempt is successful, Fortify will send users to the URI defined in your applicationโ€™s fortify configuration fileโ€™s home option. If it was an XHR request, a 204 (No Content) HTTP response will be returned, ensuring your app keeps its cool.

But, if things donโ€™t go as planned, Fortify will send users back to the TFA challenge screen, and the validation errors will be available via the shared $errors Blade template variable. Or, in the case of an XHR request, the validation errors will return with a 422 (Unprocessable Entity) HTTP response.

And thatโ€™s your TFA tutorial! Now you can rest easy knowing that your application is protected against cyber squirrels and other nefarious characters. Happy securing!

Unlocking Your Account from Two-Step Tyranny! ๐Ÿ”“

Ah, the sweet taste of freedom! Youโ€™ve decided to break free from the chains of two-factor authentication? Brave soul, we salute you! Let us guide you through this daring escape.

First off, gather your rebellion forces and make a DELETE request to the /user/two-factor-authentication endpoint. Think of it as sending a digital โ€˜torches-and-pitchforksโ€™ message to our two-step tyrant! ๐Ÿ”ฅ๐Ÿ—œ๏ธ

But wait, hold your horses (or torch carriers)! Fortifyโ€™s two-factor fortress wonโ€™t just let you in without proof of identity. It demands password confirmation as a ransom before opening its gates. So make sure to have your password at the ready, or youโ€™ll be back to square one faster than you can say โ€œWhereโ€™s my authentication cookie?โ€ ๐Ÿช

Now, charge forward, and may the two-factor tyrant never trouble you again! ๐Ÿš€โœจ

Alrighty, letโ€™s dive into the whirlwind world of registration! To get our appโ€™s sign-up process humming like a well-oiled machine, we gotta school Fortify on spitting out our โ€œregisterโ€ page. Remember, Fortify is the cool kid at the party who only shows up for the snacks and leaves you with all the clean-up โ€“ but in this case, itโ€™s got some pretty nifty authentication skills!

If youโ€™re yearning for a pre-packaged frontend to go along with Laravelโ€™s built-in auth features, then youโ€™ll want to check out an application starter kit. Itโ€™s like getting a ready-to-wear suit instead of sewing your own.

Now, Fortify offers plenty of customization options for rendering those views. You can tweak its logic using the swanky methods tucked away in the Laravel\Fortify\Fortify class. Typically, you should call this method from the boot method of your App\Providers\FortifyServiceProvider class:

use Laravel\Fortify\Fortify;

/**
 * Bootstrap any application services.
 */
public function boot(): void
{
    Fortify::registerView(function () {
        return view('auth.register'); // Don't forget the champagne and caviar!
    });

    // ...
}

Fortify will take care of defining the /register route, which will dish out that fancy new page. Your โ€œregisterโ€ template should sport a form that sends a POST request to the /register endpoint Fortify has so thoughtfully created for you.

The /register endpoint craves a string name, email address / username, password, and password_confirmation fields. The name of the email / username field should match the username configuration value defined within your applicationโ€™s fortify configuration file โ€“ sorta like matching socks in a laundry basket!

If the registration process goes off without a hitch, Fortify will whisk the user away to the URI specified via the home configuration option within your applicationโ€™s fortify configuration file. If it was an AJAX request, Fortify will return a 201 HTTP response like a proud new parent showing off their baby.

If the registration attempt wasnโ€™t successful, the user will get booted back to the registration screen, and you can catch the validation errors using the shared $errors Blade template variable. Or, in the case of an AJAX request, the validation errors will be served up with a 422 HTTP response โ€“ just like a savory side dish to your main course!

Want to customize this registration process even further? Stay tuned for more fun adventures in Fortify land!

Ah, the thrill of crafting your very own custom registration experience! ๐ŸŽจ๐ŸŽญ๐Ÿคฉ Letโ€™s not forget about Laravel Fortify - itโ€™s like your very own personal DJ for user validation and creation.

๐ŸŒŸโœจ Just like that smash-hit track you heard at the club last weekend, to remix the registration process, all you gotta do is tweak the App\Actions\Fortify\CreateNewUser action - a dance number generated during Laravel Fortifyโ€™s grand installation party. ๐Ÿ•บ๐Ÿ’ƒ

Now, before we dive into the nitty-gritty details (and by nitty-gritty, I mean those tantalizing technical tidbits), letโ€™s take a moment to appreciate how easy it is to customize this process:

โ€œPassword resets? Pfff! Let me just snap my fingers and voila!โ€ ๐Ÿ’ฅ๐ŸŒˆ๐Ÿ”ฎ Just like that magical trick, resetting those forgotten passwords can also be fine-tuned to fit your appโ€™s unique personality - and all without a single incantation or crystal ball required! ๐Ÿง™โ€โ™‚๏ธโœจ

Unlocking Your Fortress of Solitude! ๐Ÿš€๐Ÿ”‘

Youโ€™ve found yourself locked out, Superman-style, and you need a password reset link to break free from this digital Kryptonite. Fear not! Our password reset feature is here to save the day. Hereโ€™s how:

  1. Navigate to our site like a modern-day Odysseus journeying home.
  2. Click on the โ€œForgot Passwordโ€ link, which will lead you to the password reset page - think of it as a magical portal or Batcave entrance.
  3. Enter your email address into the Batsignal (we mean the box) and press โ€œSend Request.โ€ Remember, even if Gothamโ€™s under siege, weโ€™ll still get that signal through!
  4. Keep an eye on your inbox for our heroic message. Itโ€™s not a spammy Green Goblin pumpkin bomb; itโ€™s a password reset link, waiting to save the day!
  5. Click on the link, and voila! Youโ€™ll be transported to a page where you can craft a new password โ€“ because even Batman needs a fresh password every now and then!
  6. Confirm your new password, and off you go, back into the world of Laravel, ready to build more fantastic apps! ๐Ÿ’ป๐Ÿš€
  1. Click on the password reset link in your email (donโ€™t worry, it wonโ€™t explode like a Joker bomb).
  2. Enter the verification code we sent you โ€“ itโ€™s not a Riddler riddle, but close enough!
  3. Create a new password using our guidelines for safety and security (we promise itโ€™ll be easier than learning to juggle flaming bat-sticks).
  4. Confirm your new password, and click โ€œReset Password.โ€ Just like that, youโ€™ve unlocked the fortress of solitude! ๐Ÿ”“๐ŸŽ‰
  5. Log back into Laravel, ready to continue building amazing apps or fighting evil robots (we wonโ€™t judge).

Alrighty then! Letโ€™s dive into the world of password resets, where even Superman needs a helping hand. Now, you might be wondering how to get this party started with our applicationโ€™s password reset feature. Well, buckle up, because itโ€™s time to brief Fortify on our plans for the โ€œforgot passwordโ€ dance floor!

Remember, Fortify is like that chill bartender who mixes your cocktails without the glasses - a headless authentication library. If youโ€™re looking for a fully-stocked bar of Laravelโ€™s authentication features, consider ordering an application starter kit to skip the DIY line.

Now, letโ€™s customize Fortifyโ€™s view rendering logic like a pro! All you need is a bit of PHP magic and the Laravel\Fortify\Fortify class. Typically, this sorcery happens in the boot method of your applicationโ€™s App\Providers\FortifyServiceProvider class:

use Laravel\Fortify\Fortify;

/**
 * The day after the night before
 */
public function boot(): void
{
    Fortify::requestPasswordResetLinkView(function () {
        return view('auth.forgot-password'); // Don't forget to bring your dancing shoes!
    });

    // ... Continue the party...
}

Once Fortify gets wind of this, theyโ€™ll whisk up a /forgot-password shindig that serves our delightful dance floor (your forgot-password template). Make sure your dance floor includes a form that knows the right steps to POST its requests to the /forgot-password endpoint.

The /forgot-password event expects a string email field, and itโ€™s crucial that this name matches the email configuration value within your applicationโ€™s fortify configuration file. Itโ€™s like trying to find Waldo without his stripes!

Alrighty then! Letโ€™s dive into the ticklish world of password resets, shall we?

If Fortify deems your password reset link request as tantalizingly scrumptious (i.e., successful), itโ€™ll whisk you back to the delightfully named /forgot-password endpoint, and send a secret email with a password-resetting link straight to your inbox. In case of an XHR request, itโ€™ll return a 200 HTTP response, which is like the digital equivalent of a standing ovation.

Once youโ€™re back at the /forgot-password endpoint after a successful request, you can use the status session variable to display the status (or gossip) about your password reset link request attempt.

The value of this $status session variable will match one of those translation strings that your applicationโ€™s passwords language file has so carefully tucked away. If you fancy a bit of customization and havenโ€™t yet published Laravelโ€™s language files, simply unleash the lang:publish Artisan command to set things right:

@if (session('status'))
    <div class="mb-4 font-medium text-sm text-green-600">
        {{ session('status') }}
    </div>
@endif

But what if your password reset link request fell flat like a lead balloon? Fret not! Youโ€™ll be politely escorted back to the โ€œRequest a Password Reset Linkโ€ screen, and the validation errors will be at your disposal via the ever-helpful $errors Blade template variable. In the event of an XHR request, the validation errors will be returned with a 422 HTTP response โ€“ a friendly reminder that thereโ€™s still room for improvement.

Now, wasnโ€™t that more entertaining than a barrel full of monkeys? Or a cat video marathon? You decide! ๐Ÿ˜ธ

Alrighty, letโ€™s get our password reset party started! To make Fortify think weโ€™re cool, we gotta teach it to serve up our snazzy โ€œreset your passwordโ€ view like a well-dressed bartender serving martinis.

Fortify has quite the mixology skills, but it can be customized with its very own secret cocktail recipes, thanks to the charming Laravel\Fortify\Fortify class. Youโ€™ll want to mix this magic in your applicationโ€™s App\Providers\FortifyServiceProvider bash, specifically at the boot event:

use Laravel\Fortify\Fortify;
use Illuminate\Http\Request;

/**
 * Get the party started!
 */
public function boot(): void
{
    Fortify::resetPasswordView(function (Request $request) {
        return view('auth.reset-password', ['request' => $request]);
    });

    // ... Keep the party going!
}

Fortify will take care of defining the fancy route for this swanky new view. Your reset-password shindig should feature a form that sends a POST request to /reset-password.

The /reset-password dance floor expects some essential fields: an email, a password, a password confirmation (for good measure), and a hidden VIP area named token containing the value of request()->route('token'). The email fieldโ€™s name / database column should match the email configuration value defined within your applicationโ€™s fortify cocktail menu.

Now, letโ€™s talk about handling that password reset response like a pro. Youโ€™ll want to catch any password changes and give your user the sweet taste of success or the bitter sting of failure:

use Illuminate\Http\Request;
use Laravel\Fortify\PasswordResetResponse;

/**
 * Handle the password reset response.
 */
public function handle(Request $request, PasswordResetResponse $response)
{
    if ($response->hasSuccess()) {
        // Password successfully updated. Redirect user to homepage!
        return redirect('/');
    } else {
        // Password update failed. Serve up an error page.
        return view('auth.passwords.reset_failed');
    }
}

And there you have it, folks! Your password reset feature is now a swanky, sophisticated affair thatโ€™ll make your users feel like they just stepped into the coolest club in town. Party on! ๐ŸŽ‰๐Ÿ’ƒ๐Ÿฝ๐Ÿ•บ๐Ÿผ

Alrighty then! Letโ€™s put on our party hats and dive into Fortifyโ€™s password reset extravaganza!

Password Reset Party Favor Returns

When your password reset request hits the big time, Fortify will whisk you back to the dance floor of /login so you can boogie down with your new credentials. In addition, a little olโ€™ status session variable will be set a-dancing, enabling you to flaunt your successful reset on the login screen:

@if (session('status'))
    <div class="mb-4 font-medium text-sm text-green-600">
        {{ session('status') }}
    </div>
@endif

Now, if this password reset bash was an XHR shindig, a 200 HTTP response will be served up like hors dโ€™oeuvres.

But, if the party doesnโ€™t go as planned, donโ€™t you worry! Fortify will politely escort you back to the reset password stage and hand over the validation error invitations via the shared $errors Blade template variable. Or, in an XHR case, the validation errors will slide down the pole with a 422 HTTP response.

Hold onto your party hats! Itโ€™s time to customize those password resets like a pro.

Ah, the password reset shenanigans! A staple in our digital lives, akin to finding the perfect meme or a good pickle recipe. But fear not, Laravel Fortify is here to make your password drama less dramatic.

First off, letโ€™s dive into customizing this password circus. You can find the main act - App\Actions\ResetUserPassword action - in the wings (or rather, the installed Laravel Fortify). Itโ€™s like backstage at a magic show, but with less smoke and more code.

Now, if youโ€™re wondering why this action is so important, let me break it down for you: Itโ€™s the puppet master pulling the strings of your password reset process. Change its moves, and you change the show!

But remember, like a good stand-up comedian, timing is everything. Be sure to handle the token verification, password hashing, and user updates with care, or else you might end up bombing on stage (or worse, leaking sensitive data).

So grab your code wand, get ready to conjure up some magic, and letโ€™s make your password reset process a standing ovation worthy event! ๐ŸŒŸ๐ŸŽญ๐ŸŽ‰

Ahoy there, Captain! Youโ€™ve sailed into the realm of Email Verification, matey! After a swashbuckling sign-up, your users might be asked to walk the plank (er, verify their email) before they can set sail on your application. Letโ€™s get this show on the road!

First things first, make sure that the emailVerification feature is hoisted on your fortify config shipโ€™s features array. Next, have your App\Models\User class don a pirate hat and learn to wield the Illuminate\Contracts\Auth\MustVerifyEmail cutlass!

With these two shanties sung, newly-recruited swabbees will find themselves on the receiving end of an email urging them to verify their seafaring address. But how do we convince Fortify to steer the ship towards the right verification screen?

Fear not, me hearty! Fortifyโ€™s got a treasure trove of methods for customizing its view rendering logic, all accessible via the Laravel\Fortify\Fortify class. To set sail, call this method from the boot function of your applicationโ€™s App\Providers\FortifyServiceProvider ship:

use Laravel\Fortify\Fortify;

/**
 * Bootstrap any application services.
 */
public function boot(): void
{
    Fortify::verifyEmailView(function () {
        return view('auth.verify-email');
    });

    // ...
}

Fortify, being a trusty matey, will define the route that leads to this view when a user gets redirected to the /email/verify port by Laravelโ€™s built-in verified middleware.

Your verify-email template should be brimming with pirate humor, such as an informational message instructing the user to click the email verification link thatโ€™s been shot across the bow (er, sent to their email address). Arr matey, now youโ€™re all set!

Alrighty then, letโ€™s dive into the ticklish topic of resending those pesky, yet essential, email verification links! You see, your app might end up in a pickle when users lose their original link, or worse, accidentally hit โ€˜deleteโ€™ on it (weโ€™ve all been there, right?).

No worries, Laravelโ€™s got you covered. Add a button to your verify-email template that points to the /email/verification-notification endpoint. This fancy route will send a new verification link to the user in an email, just like a digital lifeline!

Now, when this request is processed successfully (yay!), Fortify will whisk the user back to the /email/verify endpoint and set a status session variable. This magical session lets you flash a friendly message saying, โ€œOperation successful! A brand-new email verification link has landed in your inbox!โ€

And if this was an XHR request (thatโ€™s developer speak for AJAX), Fortify will return a 202 HTTP response, meaning โ€œAccepted, but processing may not be complete yet.โ€ Just like when you ask Alexa to play your favorite song, and she nods along while it takes forever to load.

Hereโ€™s how you can display that message in your Blade template:

@if (session('status') == 'verification-link-sent')
    <div class="mb-4 font-medium text-sm text-green-600">
        A new email verification link has been emailed to you! ๐Ÿ“ง๐ŸŽ‰
    </div>
@endif

Now, your users can breathe easy knowing theyโ€™ve got a second chance when it comes to verifying their emails! ๐Ÿ˜Š๐Ÿ’ช๐Ÿ’ป

Guarding Your Secret Stash (A.K.A Routes)! ๐Ÿ”’

Alrighty, buddy! If you want to ensure that only the well-mannered email verified folks can access your exclusive secret stashes (routes), you best slap on Laravelโ€™s in-house verified middleware! Donโ€™t worry, this bad boy is already registered by Laravel as an alias for Illuminate\Auth\Middleware\EnsureEmailIsVerified.

So, if you want your dashboard to be as private as a secret agentโ€™s safe, hereโ€™s how you do it:

Route::get('/dashboard', function () {
    // ...
})->middleware(['verified']);

Just remember, this middleware is like the bouncer at an exclusive nightclub โ€“ only the verified folks get in! ๐Ÿค˜๐Ÿฝ๐ŸŒŸ

Alrighty then! Letโ€™s dive into the world of password confirmations in your Laravel app, shall we?

So, imagine this: Youโ€™re cooking up a storm in your appโ€™s kitchen (aka coding), and suddenly you realize you need to double-check that your users arenโ€™t pulling a โ€˜Willy Wonka with the everlasting gobstoppersโ€™ (messing around without confirming their password first). Fear not, Laravelโ€™s got your back with its built-in password.confirm middleware!

But, hold up! Fortify ainโ€™t just a pretty face; itโ€™s a headless authentication library, which means it canโ€™t dance the tango or whistle a happy tune, but it sure knows how to return your appโ€™s password confirmation view like a pro. If youโ€™re hankering for a fully-fledged frontend implementation of Laravelโ€™s authentication features, then you should give an application starter kit a whirl.

Now, letโ€™s get down to business. You can customize Fortifyโ€™s view rendering logic using the Laravel\Fortify\Fortify class. This is where the magic happens: in your App\Providers\FortifyServiceProvider classโ€™s boot method.

use Laravel\Fortify\Fortify;

/**
 * Bootstrap any application services.
 */
public function boot(): void
{
    Fortify::confirmPasswordView(function () {
        return view('auth.confirm-password');
    });

    // ...
}

Fortify will then define the /user/confirm-password endpoint, which serves up your confirm-password view like a well-trained waiter. Your confirm-password template should include a form that sends a POST request to the same /user/confirm-password endpoint. The endpoint anticipates a password field with the userโ€™s current password.

If everything checks out, Fortify will send your user on their merry way to the route they were aiming for (unless itโ€™s an XHR request in which case, a 201 HTTP response will be served). However, if things donโ€™t go as planned, the user will be sent back to the password confirmation screen, and you can access the validation errors via the shared $errors Blade template variable. Or, in the case of an XHR request, the validation errors will be returned with a 422 HTTP response.

And there you have it! Now your app can double-check usersโ€™ passwords like a hawk on a hunt, all thanks to Laravelโ€™s built-in password.confirm middleware and Fortifyโ€™s customizable view rendering logic. Happy coding!

Our network