Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XEP-0077 In-band registration with Strophe.js and openfire usage

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);
});
like image 724
user1054134 Avatar asked Feb 21 '23 15:02

user1054134


1 Answers

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 [email protected] you would set it to "example.com", not "http://localhost:7070/http-bind/" as in your code.

like image 200
MattJ Avatar answered Apr 27 '23 18:04

MattJ