Additional email address per user account support

I did the following:

./launcher enter app
rails c
UserEmail.where(user_id: 7, primary: false).destroy_all
UserEmail.create!(user: User.find_by_username("user7"), email: "newemail@example.com")
exit
exit
./launcher restart app

I don’t know if this is what I did wrong, but I only ran the delete line this time. Restarted the app, and refreshed the website. The secondary email was gone! So I went ahead and did the rest on the web UI and changed the primary to secondary as it is no longer a block.

I take that back, changing the email via the web sends a confirmation to the valid email address, but retains the invalid email address once you land back to the user’s preference page or user admin page.
Now I’m not sure what to do :frowning:

EDIT:

At the risk of spamming this thread, I figured it out.

Once in rails c
I removed all the emails - I just didn’t know how to set an email as Primary, that’s why everytime I re-add the valid email, it just gets added as a secondary email.

# Remove all secondary emails
UserEmail.where(user_id: 1234, primary: false).destroy_all
# Remove primary email
UserEmail.where(user_id: 1234, primary: true).destroy_all

# Set primary email
UserEmail.create!(user_id: 1234, email: "validemail@example.com", primary: true)

This goes without saying, it skips validation, but you’ve humanly validated it from the merged account previously so hopefully other folks can use this example. Only thing left to do is send the password reset email once you’ve restarted the app.

5 Likes