Software /
code /
prosody-modules
Changeset
2929:3a104a900af1
mod_register_web: Pass username to generate_register_response
author | Michel Le Bihan <michel@lebihan.pl> |
---|---|
date | Tue, 13 Mar 2018 21:12:21 +0100 |
parents | 2928:b0d92332b87f |
children | 2930:9a62780e7ee2 |
files | mod_register_web/mod_register_web.lua |
diffstat | 1 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_register_web/mod_register_web.lua Mon Mar 12 12:26:15 2018 +0100 +++ b/mod_register_web/mod_register_web.lua Tue Mar 13 21:12:21 2018 +0100 @@ -117,6 +117,7 @@ local username = form.username; local password = form.password; local confirm_password = form.confirm_password; + local jid = nil; form.username, form.password, form.confirm_password = nil, nil, nil; local prepped_username = nodeprep(username); @@ -139,6 +140,7 @@ end local ok, err = usermanager.create_user(prepped_username, password, module.host); if ok then + jid = prepped_username.."@"..module.host local extra_data = {}; for field in pairs(extra_fields) do local field_value = form[field]; @@ -156,17 +158,17 @@ ip = origin.conn:ip(), }); end - return ok, err; + return jid, err; end -function generate_success(event, form) - return render(success_tpl, { jid = nodeprep(form.username).."@"..module.host }); +function generate_success(event, jid) + return render(success_tpl, { jid = jid }); end -function generate_register_response(event, form, ok, err) +function generate_register_response(event, jid, err) event.response.headers.content_type = "text/html; charset=utf-8"; - if ok then - return generate_success(event, form); + if jid then + return generate_success(event, jid); else return generate_page(event, { register_error = err }); end @@ -177,8 +179,8 @@ local form = http.formdecode(request.body); verify_captcha(request, form, function (ok, err) if ok then - local register_ok, register_err = register_user(form, request); - response:send(generate_register_response(event, form, register_ok, register_err)); + local jid, register_err = register_user(form, request); + response:send(generate_register_response(event, jid, register_err)); else response:send(generate_page(event, { register_error = err })); end