paully21
(Paul Apostolos)
14 مارس 2016، 4:43م
1
We have a section on our website that allows users to manage their Discourse account preferences. Most of our users only use Discourse as a sort of mailing list, so we made it easy for them to manage that activity within their website account.
I need to be able to modify the user’s email address via an api call. We do all sorts of stuff with api calls now, but I can’t figure out how to change the email address.
I’m guessing I need the update action of the UsersEmailController
(https://github.com/discourse/discourse/blob/master/app/controllers/users_email_controller.rb ) but I don’t know how to reach that endpoint.
Does anyone know the URL of the endpoint to change a user’s email address (using the api key and api username method)?
Thanks!
إعجاب واحد (1)
Falco
(Falco)
14 مارس 2016، 4:46م
2
Did you try:
PUT https://meta.discourse.org/users/falco/preferences/email
with email
parameter?
3 إعجابات
zogstrip
(Régis Hanol)
14 مارس 2016، 4:48م
3
If you look at the routes.rb
file you will see this line
put "users/:username/preferences/email" => "users_email#update", constraints: {username: USERNAME_ROUTE_FORMAT}
which means you need to PUT https://your.discourse.org/users/<username>/preferences/email
Got ninja-ed by @Falco
3 إعجابات
paully21
(Paul Apostolos)
14 مارس 2016، 4:49م
4
Yep…And I got a 200 OK, but it didn’t change the email address in Discourse.
إعجاب واحد (1)
Falco
(Falco)
14 مارس 2016، 4:50م
5
Looks like it send an e-mail for confirmation! Did you get one ?
paully21
(Paul Apostolos)
14 مارس 2016، 4:52م
6
It does send a confirmation…Ah…So it works and I had it correct. I guess I’m not going crazy.
Now, is there a way to not send the confirmation and just confirm it straight away?
Falco
(Falco)
14 مارس 2016، 4:54م
7
I don’t think so, unless you wanna mess without the api.
But confirmations are good to stop typos!
إعجابَين (2)
paully21
(Paul Apostolos)
14 مارس 2016، 5:05م
8
Cool…Thanks for all the help!
Paul
إعجاب واحد (1)