4

I'm trying to register a new user on openfire server with the strophe plugin but it doesn't connect for the registration. The description here https://github.com/metajack/strophejs-plugins/tree/master/register doesn't bring me any further :( Do I have to establish a connection before? This is what I try when clicking a button to register:

$("#RegButton").click(function () {
var callback = function (status) {
if (status === Strophe.Status.REGISTER) {
    connection.register.fields.username = "juliet";
    connection.register.fields.password = "R0m30";
    connection.register.submit();
} else if (status === Strophe.Status.REGISTERED) {
    console.log("registered!");
    connection.authenticate();
} else if (status === Strophe.Status.CONNECTED) {
    console.log("logged in!");
} else {
    // every other status a connection.connect would receive
}
};
connection.register.connect("http://localhost:7070/http-bind/", callback);
});
user1054134
  • 443
  • 1
  • 4
  • 21

2 Answers2

4

On this line:

connection.register.connect("http://localhost:7070/http-bind/", callback);

connection should be a Strophe.Connection object already created with your service URL ("http://localhost:7070/http-bind/").

The first parameter to connection.register.connect() is the host that you want to register an account on. That is, for a JID of user@example.com you would set it to "example.com", not "http://localhost:7070/http-bind/" as in your code.

MattJ
  • 7,924
  • 1
  • 28
  • 33
4

in my case I modified the plugin, because in line 215 "if(register.length === 0)", always end my intent for register, so I commented these lines and removed a tag "x" than brings in my stanza and the register was posible. I hope this help you.

    /*
      if (register.length === 0) {
        console.log('En tra if de linea 220');
        //that._changeConnectStatus(Strophe.Status.REGIFAIL, null);
        //return;
    } else */
    this.enabled = true;
ayloj
  • 41
  • 2
  • I've also had the same issues with strophe.register.js and got around by commenting out the same lines. I'm using prosody as XMPP server. What server are you using? – Ando Sep 28 '12 at 15:17