How do I disable Laravel Fortify password confirmations when enabling two factor just for Laravel Socialite users?

Viewed 278

So I have a Laravel 8 application that uses Fortify for authentication and I recently set up two factor authentication. All is good with a normal user/password except I had previously setup login with Socialite. The way I did social logins is I set a random password for the user when they log in as making them manually set a password kind of defeats the purpose of social login(s). Where the issue comes in is with Fortify if I set

        Features::twoFactorAuthentication([
            'confirmPassword' => true,
        ])

to true I effectively make it so that the Socialite users can't setup 2FA without first resetting their password. What I think I'd like to do is just for social logins and during two factor setup disable the password confirmation. I'd like to know the answer to how to find this stuff myself but after about an hour of searching I'm hoping someone can help point me in the correct direction. I did some spelunking in the Fortify source some possible candidates are: Fortify::confirmPasswordsUsing, Fortify::authenticateThrough, or possibly modifying the authentication guard but so far all of them have either been the wrong spot or above my pay grade. Ideally when clicking enable TwoFactorAuthenticationController@store would just skip the password confirmation only for social logins. Does that make sense? How have you handled this situation?

1 Answers

you need to disable it from config/fortify.php file

'features' => [
 ....
 Features::twoFactorAuthentication([
     'confirmPassword' => false,
 ]),
 ....
]
Related