In this episode, we walk you through how to disable two-factor authentication in your app using Fortify. It's a pretty straightforward process! First, we duplicate our existing enable button code and modify it to become a "Disable Two-Factor Authentication" button. We'll make sure this button only shows when two-factor is actually enabled.
When you click this new button, we send a simple DELETE
request to Fortify. There's no need for any fancy confirmation or extra UI since disabling simply wipes out the user's two-factor data. We go over how to check the correct route using php artisan route:list
to make sure our endpoint is accurate.
Once it's all hooked up, we test it out and verify by checking the database—the two-factor secret, recovery codes, and confirmation flag are all removed. And just like that, two-factor authentication is disabled for the user! Super easy and quick to implement.