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 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);
});
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./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);
});
Share
Improve this question
edited May 2, 2012 at 14:59
user1054134
asked May 2, 2012 at 12:58
user1054134user1054134
4631 gold badge4 silver badges21 bronze badges
2 Answers
Reset to default 4On 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 [email protected] you would set it to "example."
, not "http://localhost:7070/http-bind/"
as in your code.
in my case I modified the plugin, because in line 215 "if(register.length === 0)", always end my intent for register, so I mented 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;