Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > BOOK: Professional XMPP Programming with JavaScript and jQuery
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional XMPP Programming with JavaScript and jQuery
This is the forum to discuss the Wrox book Professional XMPP Programming with JavaScript and jQuery by Jack Moffitt; ISBN: 978-0-470-54071-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional XMPP Programming with JavaScript and jQuery section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 3rd, 2014, 12:31 PM
Authorized User
Points: 182, Level: 3
Points: 182, Level: 3 Points: 182, Level: 3 Points: 182, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default In-band registration: How do I connect to the network to register new users?

Hello once again coders, anyone familiar with in-band registration? I just found out about it and decided it was the best way to hook up my app users with jabber ids, without having them go through the headache of obtaining one themselves. Since I'm new to it, this may sound as a silly question. In order to send stanzas to an XMPP server, you need to be connected through an XMPP account right? So I login with my jid to Jack's beautifully created peek console and send the following stanza to the server
Code:
$iq({type: "get", id: "reg1"}).c("query", {xmlns:"jabber:iq:register"})
which is supposed to get the register fields. The server sends back the following stanza

Code:
<iq id='reg1'
    type='result'
    to='my_jid@miqote.com/my_resource'>
<query xmlns='jabber:iq:register'>
<registered/>
<username>
my_jid
</username>
<password/>
</query>
</iq>
Note that I replaced my real jid with "my_jid"
So the puzzle is, how in the world am I supposed to register a new user if the server recognizes that my stanza is coming from an already registered user? Or is it possible to somehow send stanzas to the server without loging in with an already existing username?
  #2 (permalink)  
Old April 3rd, 2014, 12:39 PM
Wrox Author
Points: 702, Level: 10
Points: 702, Level: 10 Points: 702, Level: 10 Points: 702, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

This is not possible without the use of plugins. See the plugins at https://github.com/strophe/strophejs-plugins

The issue is that normally Strophe establishes an authenticated or anonymous session, and the legacy registration protocol must be done before a session is established.
  #3 (permalink)  
Old April 3rd, 2014, 10:18 PM
Authorized User
Points: 182, Level: 3
Points: 182, Level: 3 Points: 182, Level: 3 Points: 182, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'll take a look at that Jack. Thanks for the lead.
  #4 (permalink)  
Old April 4th, 2014, 01:21 AM
Authorized User
Points: 182, Level: 3
Points: 182, Level: 3 Points: 182, Level: 3 Points: 182, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by metajack View Post
This is not possible without the use of plugins. See the plugins at https://github.com/strophe/strophejs-plugins

The issue is that normally Strophe establishes an authenticated or anonymous session, and the legacy registration protocol must be done before a session is established.


I uploaded strophe.register.js from github to my server. Then I ran the register plugin. My final code looks like this(I'm including the html for clarity)


Quote:









<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">



<head>



<script type = "text/javascript" src="http://code.jquery.com/jquery-latest.js"> </script>


<!--include JQM -->

<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0-rc.1/jquery.mobile-1.3.0-rc.1.min.css" />

<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>

<script src="http://code.jquery.com/mobile/1.3.0-rc.1/jquery.mobile-1.3.0-rc.1.min.js"></script>




<!--include strophe and associated libraries/plugins-->

<script src='path/strophe.js'></script>
<script src='path/strophe.register.js'></script>
<script src='path/scripts/flXHR.js'></script>



<script>

$(document).ready(function(){


$("#register_button").click(function(){



var user = $("#user").val();

var pass = $("#pass").val();



var callback = function (status) {

if (status === Strophe.Status.REGISTER) {

// fill out the fields

connection.register.fields.username = user;

connection.register.fields.password = pass;

// calling submit will continue the registration process

connection.register.submit();

} else if (status === Strophe.Status.REGISTERED) {

console.log("registered!");

// calling login will authenticate the registered JID.

//connection.authenticate();

} else if (status === Strophe.Status.CONFLICT) {

console.log("Contact already existed!");

} else if (status === Strophe.Status.NOTACCEPTABLE) {

console.log("Registration form not properly filled out.")

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

console.log("The Server does not support In-Band Registration")

} else if (status === Strophe.Status.CONNECTED) {

// do something after successful authentication

} else {

// Do other stuff

}

};




var connection = new Strophe.Connection("http://bosh.metajack.im:5280/xmpp-httpbind");

connection.register.connect("miqote.com", callback, wait, hold);


});//End click

});//End document ready

</script>





<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />







<title>

XMPP In Band Registration

</title>



</head>







<body>


<div data-role = "content" style = "border:1px dotted blue;position:relative;top:20%;left:20%;width:400p x;height:300px">

Username: <input id = "user" type = "text" maxlength = "15"/>

Password: <input id = "pass" type = "password" maxlength = "15"/>

Email: <input id = "email" type = "text" maxlength = "50"/>

<div id = "register_button" data-role = "button" style = ""> Register! </div>

</div>


</body>





</html>

When I fill in the username and password fields(only these two are allowed by server), and hit "register", i get this error

"Uncaught TypeError: Cannot call method 'bind' of undefined strophe.register.js:85"

What am I missing?
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Register XMPP-Account using the Strophe.js-Register-Plugin ede32 BOOK: Professional XMPP Programming with JavaScript and jQuery 3 January 27th, 2013 01:55 PM
band-pass filter ondra .NET Framework 3.5 0 January 19th, 2010 12:26 PM
Duplicating Labels in the Detail band MountainProud Access 4 June 11th, 2008 02:10 PM
How do you get a users Network login ID lokilewis Pro VB.NET 2002/2003 2 November 28th, 2005 04:13 AM
Add/Register Users stacy Classic ASP Basics 3 January 22nd, 2004 09:45 PM



All times are GMT -4. The time now is 10:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.