1

I am building an XMPP chat app, I used strophe.js but I have no idea of how to change username and password with strophe. Thanks in advance.

beaver
  • 17,333
  • 2
  • 40
  • 66
Eric Lou
  • 159
  • 3
  • 8

1 Answers1

1

You can't change username, because it is the JID, a unique identifier of the user, created on registration to your XMPP server.

On the contrary you can change the password according to xep-0077 - In-Band Registration.

Using Strophe.js the code is:

function setPwd(pwd) {
    // jid is user account (i.e. myname@server.com)
    // name is user name (i.e. myname), must be equal to first part of jid
    var iq = $iq({
        type: 'set',
        to: jid,
        }).c('query', {
            xmlns: 'jabber:iq:register'
        })
        .c('username').t(name).up()
        .c('password').t(pwd);
    connection.sendIQ(iq, function(iq) {
        console.log("setPwd-callback", iq);
    });
}
beaver
  • 17,333
  • 2
  • 40
  • 66