Mercurial > prosody-modules
comparison mod_register_json/mod_register_json.lua @ 551:859bf77b9fbf
mod_register_json: fire user-registered event manually on the destination host. (thanks Mr. Gecko)
| author | Marco Cirillo <maranda@lightwitch.org> |
|---|---|
| date | Sat, 14 Jan 2012 21:45:37 +0000 |
| parents | d8143f627f9f |
| children | 7310ceb7564f |
comparison
equal
deleted
inserted
replaced
| 550:d8143f627f9f | 551:859bf77b9fbf |
|---|---|
| 95 if not username then | 95 if not username then |
| 96 module:log("debug", "%s supplied an username containing invalid characters: %s", user, username) | 96 module:log("debug", "%s supplied an username containing invalid characters: %s", user, username) |
| 97 return http_response(406, "Supplied username contains invalid characters, see RFC 6122.") | 97 return http_response(406, "Supplied username contains invalid characters, see RFC 6122.") |
| 98 else | 98 else |
| 99 usermanager.create_user(username, req_body["password"], req_body["host"]) | 99 usermanager.create_user(username, req_body["password"], req_body["host"]) |
| 100 module:log("debug", "%s registration data submission for %s is successful", user, username) | 100 hosts[req_body["host"]].events.fire_event("user-registered", { username = username, host = req_body["host"], source = "mod_register_json", session = { ip = req_body["ip"] } }) |
| 101 module:log("debug", "%s registration data submission for %s@%s is successful", user, username, req_body["host"]) | |
| 101 return http_response(200, "Done.") | 102 return http_response(200, "Done.") |
| 102 end | 103 end |
| 103 else | 104 else |
| 104 module:log("debug", "%s registration data submission for %s failed (user already exists)", user, username) | 105 module:log("debug", "%s registration data submission for %s failed (user already exists)", user, username) |
| 105 return http_response(409, "User already exists.") | 106 return http_response(409, "User already exists.") |
