Kan niet inloggen op een nieuwe installatie na het herstellen van een back-up

AI-generated summary

The user alltiagocom encountered login issues after restoring a backup to a new Discourse installation. After migrating from forum.example.com to example.com and restoring the backup, they were unable to log in with the new admin credentials because the system retained the old admin account (admin@forum.example.com) and its 2FA requirements. Since the 2FA was no longer accessible, they couldn’t authenticate. alltiagocom resolved the issue by using SSH to access the Discourse container, creating a new admin password via rake admin:create, and disabling 2FA for the old user using the Rails console with user.user_second_factors.destroy_all. This allowed them to log in successfully using the old email and the newly set password.

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:

:white_check_mark: Step 1: SSH into your server

ssh your-user@your-server

:white_check_mark: Step 2: Enter the Discourse app container

cd /var/discourse
./launcher enter app

:white_check_mark: 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).

:white_check_mark: Step 4: Open the Rails console

rails c

:white_check_mark: 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.


:white_check_mark: 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.


:white_check_mark: Step 7: Exit the console and container

exit

:white_check_mark: 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