If you’ve lost your phone with two-factor authentication (2FA) enabled, recovering access to your account can be challenging. Discourse doesn’t have a built-in SMS/Email-based recovery mechanism. However, you can use backup tokens, which can be used if you lose your OTP device. You can also register OTP in multiple devices or use FIDO2 keys.
If you haven’t set up backup tokens or multiple devices, you’ll need to contact the admin team to disable 2FA on your account. Alternatively, you can disable 2FA through the rails console using the following steps:
However, as noted by hellekin, this method may not work if you have backup codes enabled. To fully disable OTP, you must also remove the backup_codes entries:
Discourse have backup tokens, which are to be used if you lose your OTP device.
You can also register the OTP in multiple devices.
FIDO2 keys can also be used, and Discourse support using multiples, so you can have backup keys stored in safe places, your main one, and the ones who are backed into your device, like Android fingerprint and Windows Laptop Hello devices.
If you did neither, you will have to contact the admin team and ask then to disable 2FA on your account.
Now here is the complete solution to disable OTP for a user when they lost their ways back in: you must remove both the totps entries and the backup_codes as well, so that the call to #totp_or_backup_codes_enabled? returns false.