We recently introduced a security change: When a staff user changes their email address, for enhanced security they must confirm both new email address AND old email address.
However, this creates a problem when a staff member loses access to their old email address and wants to update their email address.
In this guide we’ll change the email address of a user (not necessarily staff) via console without the need to access old email address. Let’s get started!
These commands can also be used to force a change in a user’s email address and override the need for them to confirm by clicking on the validation email
Access Console
Connect to your Droplet via SSH, or use Putty on Windows:
ssh root@192.168.1.1
Replace 192.168.1.1
with the IP address of your Droplet.
Switch to your Discourse folder:
cd /var/discourse
Enter the container:
./launcher enter app
# or
./launcher ssh app
Access Rails Console:
rails c
Change Email Address
To personalise these for your user, input your stuff here:
or
Run these commands (each on a separate line)
u = User.find_by_id(=UserID=)
or
u = User.find_by_username("=Username=")
u.email = "=EMAIL="
u.email_tokens.create(email: u.email)
u.save!
That’s it, your email address is updated, and you should be able to login with your new email.