How to fix email addresses when using SSO?

We use a separate IDP for authentication.

Sometimes we nee to change people’s email addresses in the IDP and on Discourse for old users who haven’t logged in for a while. We do this using this:

./launcher enter app
rails c
u = User.find_by_email('')
u.update(email: '')

Except for a particular user he has a primary and secondary email address in Discourse. I think this is because this user was just merged from another. The secondary is the correct address.

I’ve tried the above command but it returns false and no changes seem to have been made.

Does anyone know how to fix this situation? I would like for the user to just have a primary address. Thanks!

1 Like

Ah, fixed it! Deleted the secondary email with the following:

UserEmail.where(user_id: 1234, primary: false).destroy_all

And then the update to email worked :slight_smile:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.