We plan to allow users to change their email address on our main site (the SSO provider). We would like to update their email in Discourse at the same time, without them having to go to their Discourse preferences, and without them having to validate their new email with Discourse. What is the best way to implement this?
I experimented with updating their email like below, but that just added a secondary Discourse email which was pending validation. I want to change their primary Discourse email with no validation. Validation is performed by the main site.
curl -X PUT "https://discourse.example.com/u/$TARGET_USERNAME/preferences/email.json" \
-H "Api-Key: $DISCOURSE_API_KEY" \
-H "Api-Username: $DISCOURSE_USERNAME" \
-H "Content-Type: application/json" \
-d '{"email": "new-address@example.com"}'