JanTay's avatar

Laravel Breeze and Two Factor Authentication

Hi All I'm using Breeze as my scaffolding for authentication but I've been asked to put in some two factor authentication where the user logins in, gets sent an email with a code, puts the code in and then is taken through to the main application pages.

I've been following the instructions from Povilas Korop on his blog at https://blog.quickadminpanel.com/add-two-factor-email-verification-to-laravel-auth/ which does exactly what I am aiming to achieve.

However, Breeze doesn't seem to come with a Login Controller so I was a bit lost at that point.

Can anyone take a look at this and give me some advice of how to achieve this with Breeze. Much appreciated. Jan

0 likes
4 replies
coder222's avatar

The "LoginController" in Breeze is AuthenticatedSessionController, where you can find this method :

    public function store(LoginRequest $request)
    {
        $request->authenticate();

        $request->session()->regenerate();

        return redirect(RouteServiceProvider::HOME);
    }

So, I think you can put the two-factor auth code either in this store method or in the LoginRequest class.

JanTay's avatar

Thanks for replying guys, much appreciated. However, I've now changed from Breeze to Fortify.

I've followed this tutorial from Penguin Digital

https://www.youtube.com/watch?v=5-P5gBM6hDM&list=PLxFwlLOncxFIbxi2gQCN3SR5e3-WB-4T2&index=7

but after a user has set up the 2fa I can't seem to get them to go anywhere else apart from the home page where the 2fa is set up.

Once they have enabled 2fa I would like them to enter their code and go to another page apart from the home page for example straight to the dashboard. It's obviously something to do with the routing but I don't have the skills to figure it out.

Can anyone assist. Thanks Jan

2 likes
JanTay's avatar

Hi Guys I've finally got this working by following a combination of the post recommended by jlrdw and some code by another guy who was on that post. Thank you all so much. Jan

1 like

Please or to participate in this conversation.