Ik had deze installatie
forum.example.com
Ik had mijn admin-account admin@forum.example.com met mijn wachtwoord en 2FA
Uiteindelijk besloot ik dit te migreren naar een nieuw domein
community.newexample.com
Voordat ik dat deed, maakte ik een back-up van forum.example.com
Vandaag besloot ik dat ik een nieuwe community wilde aanmaken op example.com
Alles geïnstalleerd, het nieuwe admin-account aangemaakt (admin@example.com), etc.
Ingelogd.
Ging naar de back-upsectie en uploadde de back-up die ik had gemaakt voor forum.example.com
Het logde me uit.
Toen ik probeerde in te loggen met de nieuwe gegevens (admin@example.com), lukte dat niet, omdat ik vermoed dat het nu de gegevens van de eerste installatie probeert te gebruiken (admin@forum.example.com)
Het probleem is ook dat ik de 2FA voor forum.example.com niet meer heb, maar daar wordt ook om gevraagd.
Wat kan ik nu doen?
UPDATE: I was able to do it by following ChatGPT’s instructions:
Step 1: SSH into your server
ssh your-user@your-server
Step 2: Enter the Discourse app container
cd /var/discourse
./launcher enter app
Step 3: Create or reset the admin user’s password
This step ensures you can log in with a known password.
rake admin:create
- When prompted, enter the email address of the admin from the backup (e.g.
admin@forum.example.com).
- Enter a new password.
- Type
Y when asked to grant admin privileges (even if the user already is an admin — it won’t hurt).
Step 4: Open the Rails console
rails c
Step 5: Find the user by email
Replace the email with the one you’re resetting:
user = User.find_by_email("admin@forum.example.com")
You should see some output showing the user object.
Step 6: Disable 2FA for that user
user.user_second_factors.destroy_all
This deletes all 2FA keys associated with that user — without affecting anyone else.
Step 7: Exit the console and container
exit
Step 8: Log in via the web
Go to your Discourse site in the browser and log in with:
- Email:
admin@forum.example.com
- Password: the one you set in Step 3
- 2FA: will no longer be required