Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Plugin for Changing Password #94

Open
the-solipsist opened this issue Jun 7, 2014 · 8 comments
Open

Plugin for Changing Password #94

the-solipsist opened this issue Jun 7, 2014 · 8 comments

Comments

@the-solipsist
Copy link

It would be useful to have a Candy plugin that allows a user to change their XMPP password via a web interface.

Currently I'm creating accounts for them with a default password, but would like to provide the ability to change their password.

@the-solipsist
Copy link
Author

Is there anything that one can do to help this along?

@benlangfeld
Copy link
Member

You could write the plugin yourself, or contract someone to write it for you :)

@the-solipsist
Copy link
Author

Thanks. Unfortunately, I'm not a coder, and am looking to get this set up for a loose collective. Guess I'll just wait to see if someone takes interest in it.

@malakada
Copy link
Member

malakada commented Aug 5, 2014

You could always learn. ;)

@the-solipsist
Copy link
Author

@melissanoelle I'd love to. Would looking at https://github.com/candy-chat/candy-plugins/blob/master/createroom/createroom.js be a good place to start?

How do I find out what the "Candy.Core.Action.Jabber.Room.Join(roomJid, null)"-equivalent for changing the password should be? I searched through the "candy" repository for "password" and here's what I see:
https://github.com/candy-chat/candy/search?q=password

But given my non-existent knowledge of JS, going through core.js and core/event.js doesn't seem to provide me an answer. :-/

@malakada
Copy link
Member

malakada commented Aug 5, 2014

That's the spirit! 👍

Mmm, maybe, yeah. For this, you'd want something that pops up a modal (which CreateRoom does), and then has a form, and then something to handle the form.

For changing the password, you'll probably want to look at what stanza the XMPP server is expecting you to send to change it. Having a read through something like this might help: http://xmpp.org/extensions/xep-0077.html#usecases-changepw

You'd next want to look at one of the plugins that does something like Candy.Core.getConnection().$iq(...) because you'll use that to build your iq type message XML stanza to send to the server. (I really need to update my plugins, I am behind, so I'm not sure which one would be best to look at off the top of my head.)

Because Candy is built on top of Strophe.js, having a read through their docs will be helpful in understanding the $iq method, which is really what Candy.Core.getConnection() is a wrapper for.

Once you understand the idea of sending and receiving these XML stanzas back and forth between your client and your server, you could probably knock this out relatively quickly. 👍

@the-solipsist
Copy link
Author

@melissanoelle: Thanks so much. I'll try and get to this over the weekend.

I'm using Prosody, and they have a very helpful community chatroom. I'll ask there if they can tell me about the correct IQ stanza that needs to be sent. After that, I'll check some existing plugins and see if I can put something together that might work. (I don't know any Javascript, so that might be a bit of an impediment, but I'll try.) Once I have that, I'll share it here for comments.

@benlangfeld
Copy link
Member

The proper spec you're looking for is XEP-0077: In-Band Registration. Examples are contained therein. The example in the spec would be built and sent like this:

var pwChangeRequest = $iq({
  type: 'set',
  to: 'shakespeare.lit'
})
.c('query', {xmlns: 'jabber:iq:register'})
.c('username').t('bill').up()
.c('password').t('newpass');

Candy.Core.getConnection().sendIQ(
  pwChangeRequest,
  function () {
    console.log("Password change was successful.")
  },
  function (responseStanza) {
    console.log("Password change failed.");
    console.log(responseStanza);
  }
);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants