Software /
code /
prosody
Comparison
plugins/mod_register.lua @ 927:cc180d25dbeb
Fixed: mod_register: Node prepping was not being applied to usernames (part of issue #57)
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 30 Mar 2009 02:30:06 +0500 |
parent | 926:ceaa7d54a3cb |
child | 1042:a3d77353c18a |
comparison
equal
deleted
inserted
replaced
926:ceaa7d54a3cb | 927:cc180d25dbeb |
---|---|
11 local st = require "util.stanza"; | 11 local st = require "util.stanza"; |
12 local usermanager_user_exists = require "core.usermanager".user_exists; | 12 local usermanager_user_exists = require "core.usermanager".user_exists; |
13 local usermanager_create_user = require "core.usermanager".create_user; | 13 local usermanager_create_user = require "core.usermanager".create_user; |
14 local datamanager_store = require "util.datamanager".store; | 14 local datamanager_store = require "util.datamanager".store; |
15 local os_time = os.time; | 15 local os_time = os.time; |
16 local nodeprep = require "util.encodings".stringprep.nodeprep; | |
16 | 17 |
17 module:add_feature("jabber:iq:register"); | 18 module:add_feature("jabber:iq:register"); |
18 | 19 |
19 module:add_iq_handler("c2s", "jabber:iq:register", function (session, stanza) | 20 module:add_iq_handler("c2s", "jabber:iq:register", function (session, stanza) |
20 if stanza.tags[1].name == "query" then | 21 if stanza.tags[1].name == "query" then |
60 else | 61 else |
61 local username = query:child_with_name("username"); | 62 local username = query:child_with_name("username"); |
62 local password = query:child_with_name("password"); | 63 local password = query:child_with_name("password"); |
63 if username and password then | 64 if username and password then |
64 -- FIXME shouldn't use table.concat | 65 -- FIXME shouldn't use table.concat |
65 username = table.concat(username); | 66 username = nodeprep(table.concat(username)); |
66 password = table.concat(password); | 67 password = table.concat(password); |
67 if username == session.username then | 68 if username == session.username then |
68 if usermanager_create_user(username, password, session.host) then -- password change -- TODO is this the right way? | 69 if usermanager_create_user(username, password, session.host) then -- password change -- TODO is this the right way? |
69 session.send(st.reply(stanza)); | 70 session.send(st.reply(stanza)); |
70 else | 71 else |
131 end | 132 end |
132 ip.time = os_time(); | 133 ip.time = os_time(); |
133 end | 134 end |
134 end | 135 end |
135 -- FIXME shouldn't use table.concat | 136 -- FIXME shouldn't use table.concat |
136 username = table.concat(username); | 137 username = nodeprep(table.concat(username)); |
137 password = table.concat(password); | 138 password = table.concat(password); |
138 if usermanager_user_exists(username, session.host) then | 139 if usermanager_user_exists(username, session.host) then |
139 session.send(st.error_reply(stanza, "cancel", "conflict")); | 140 session.send(st.error_reply(stanza, "cancel", "conflict")); |
140 else | 141 else |
141 if usermanager_create_user(username, password, session.host) then | 142 if usermanager_create_user(username, password, session.host) then |