Software / code / prosody
Comparison
plugins/mod_register.lua @ 5720:449399a7e136
Merge
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 29 Jun 2013 14:45:47 +0100 |
| parent | 5707:36a289e9244c |
| child | 5763:0e52f1d5ca71 |
comparison
equal
deleted
inserted
replaced
| 5719:84025249fc04 | 5720:449399a7e136 |
|---|---|
| 70 | 70 |
| 71 module:add_feature("jabber:iq:register"); | 71 module:add_feature("jabber:iq:register"); |
| 72 | 72 |
| 73 local register_stream_feature = st.stanza("register", {xmlns="http://jabber.org/features/iq-register"}):up(); | 73 local register_stream_feature = st.stanza("register", {xmlns="http://jabber.org/features/iq-register"}):up(); |
| 74 module:hook("stream-features", function(event) | 74 module:hook("stream-features", function(event) |
| 75 local session, features = event.origin, event.features; | 75 local session, features = event.origin, event.features; |
| 76 | 76 |
| 77 -- Advertise registration to unauthorized clients only. | 77 -- Advertise registration to unauthorized clients only. |
| 78 if not(allow_registration) or session.type ~= "c2s_unauthed" then | 78 if not(allow_registration) or session.type ~= "c2s_unauthed" then |
| 79 return | 79 return |
| 80 end | 80 end |
| 113 end | 113 end |
| 114 | 114 |
| 115 module:log("info", "User removed their account: %s@%s", username, host); | 115 module:log("info", "User removed their account: %s@%s", username, host); |
| 116 module:fire_event("user-deregistered", { username = username, host = host, source = "mod_register", session = session }); | 116 module:fire_event("user-deregistered", { username = username, host = host, source = "mod_register", session = session }); |
| 117 else | 117 else |
| 118 local username = nodeprep(query:get_child("username"):get_text()); | 118 local username = nodeprep(query:get_child_text("username")); |
| 119 local password = query:get_child("password"):get_text(); | 119 local password = query:get_child_text("password"); |
| 120 if username and password then | 120 if username and password then |
| 121 if username == session.username then | 121 if username == session.username then |
| 122 if usermanager_set_password(username, password, session.host) then | 122 if usermanager_set_password(username, password, session.host) then |
| 123 session.send(st.reply(stanza)); | 123 session.send(st.reply(stanza)); |
| 124 else | 124 else |