Question

Hi everyone i am trying to register new account on my local openfire server using strophe.js and strophe.register.js plugin by following the steps for registration provide on many websites.But i get error in my strophe.register.js file at line var auth_old = conn.authenticate.bind(conn); that conn.authenticate is undefined below is the my code
code of my js file

$(document).ready(function () {              
var conn = new Strophe.Connection(
    "http://jabber.local/http-bind");
console.log(conn);
var callback = function (status) {

    if ( status === Strophe.Status.REGISTERING ) {
        console.log('REGISTERING')
    conn.authenticate();
    }

    else if ( status === Strophe.Status.REGIFAIL ) {
        console.log('REGIFAIL')
    }

    else if ( status === Strophe.Status.REGISTER ) {
        console.log('REGISTER')
        conn.register.fields.username = "joe"
                conn.register.fields.password = "doe"
                conn.register.submit();
    }

    else if ( status === Strophe.Status.SUBMITTING ) {
        console.log('SUBMITTING')
    }

    else if ( status === Strophe.Status.SBMTFAIL ) {
        console.log('SBMTFAIL')
        console.log('Something went wrong...');
    }

    else if ( status === Strophe.Status.REGISTERED ) {
        console.log('REGISTERED')

        console.log('Your account has been created successfully and is ready to use!');

    }

}   

conn.register.connect("example.com", callback);

});

and the html file code is

<html>
<head>

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js'></script>
<script src='../scripts/strophe.js'></script>
<script type="text/javascript" src="../scripts/strophe.register.js"></script>
<script src='../scripts/flXHR.js'></script>
<script src='../scripts/strophe.flxhr.js'></script>

<link rel='stylesheet' href='hello.css'>
<script src='hello.js'></script>
</head>
<body>
<h1>Hello</h1>

<div id='log'>
</div>

<!-- login dialog -->
<div id='login_dialog' class='hidden'>
  <label>JID:</label><input type='text' id='jid'>
  <label>Password:</label><input type='password' id='password'>
</div>
</body>
</html>

can enyone tell my why this happend and how to solve this.One more thing i also comment the lines that most site said to do.

/* if (register.length === 0) {
        conn._changeConnectStatus(Strophe.Status.REGIFAIL, null);
        return true;
    }*/
this.enabled = true;
Was it helpful?

Solution

Just noticed that you are using the older version of the plugin. Please update the strophe.register.js from https://github.com/metajack/strophejs-plugins/blob/master/register/strophe.register.js

I have checked the latest version it does not have below line

var auth_old = conn.authenticate.bind(conn);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top