plugins/register.lua

changeset 343
0d8fb22404c3
parent 342
7aed4bc4949c
equal deleted inserted replaced
342:7aed4bc4949c 343:0d8fb22404c3
3 local xmlns_register = "jabber:iq:register"; 3 local xmlns_register = "jabber:iq:register";
4 4
5 function verse.plugins.register(stream) 5 function verse.plugins.register(stream)
6 local function handle_features(features_stanza) 6 local function handle_features(features_stanza)
7 if features_stanza:get_child("register", "http://jabber.org/features/iq-register") then 7 if features_stanza:get_child("register", "http://jabber.org/features/iq-register") then
8 stream:send_iq(verse.iq({ to = stream.host_, type = "set" }) 8 local request = verse.iq({ to = stream.host_, type = "set" })
9 :tag("query", { xmlns = xmlns_register }) 9 :tag("query", { xmlns = xmlns_register })
10 :tag("username"):text(stream.username):up() 10 :tag("username"):text(stream.username):up()
11 :tag("password"):text(stream.password):up() 11 :tag("password"):text(stream.password):up();
12 , function (result) 12 if stream.register_email then
13 request:tag("email"):text(stream.register_email):up();
14 end
15 stream:send_iq(request, function (result)
13 if result.attr.type == "result" then 16 if result.attr.type == "result" then
14 stream:event("registration-success"); 17 stream:event("registration-success");
15 else 18 else
16 local type, condition, text = result:get_error(); 19 local type, condition, text = result:get_error();
17 stream:debug("Registration failed: %s", condition); 20 stream:debug("Registration failed: %s", condition);

mercurial