Command line disable Two Factor Authentication

Sorry, setting SiteSetting.enforce_second_factor = "no" will not solve your problem. You need to remove the second factor record for your user.

To do that, enter the rails console, then you need to find your user ID. To do that run:

id  = User.find_by(username: '<your_username>').id

Replace <your_username> with your Discourse username. Make sure to keep the quotation marks. When you run the command, you should see a number returned. That number is your user ID. It has been assigned to the variable id.

Then you need to find the UserSecondFactor record that is associated with your user. This command uses the id variable that you set with the first command:

second_factor = UserSecondFactor.find_by(user_id: id)

When you run that command, you should see some output in the console that shows your second factor record.

Now destroy the record:

second_factor.destroy

You can exit the console after running that command. You should be able to login to your site after running it.

Let us know if you have any problems with this.