Software / code / prosody-modules
Comparison
mod_register_web/mod_register_web.lua @ 753:9d5731af2c27
Merge with Oliver Gerlich
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 27 Jul 2012 14:29:59 +0100 |
| parent | 746:03595194075a |
| child | 791:b9d149936764 |
comparison
equal
deleted
inserted
replaced
| 752:9bbd99f2057a | 753:9d5731af2c27 |
|---|---|
| 1 local captcha_options = module:get_option("captcha_options", {}); | 1 local captcha_options = module:get_option("captcha_options", {}); |
| 2 local nodeprep = require "util.encodings".stringprep.nodeprep; | |
| 2 | 3 |
| 3 function generate_captcha(display_options) | 4 function generate_captcha(display_options) |
| 4 return (([[ | 5 return (([[ |
| 5 <script type="text/javascript" | 6 <script type="text/javascript" |
| 6 src="http://www.google.com/recaptcha/api/challenge?k=$$recaptcha_public_key$$"> | 7 src="http://www.google.com/recaptcha/api/challenge?k=$$recaptcha_public_key$$"> |
| 48 </form> | 49 </form> |
| 49 </body></html>]]; | 50 </body></html>]]; |
| 50 end | 51 end |
| 51 | 52 |
| 52 function register_user(form) | 53 function register_user(form) |
| 53 if usermanager.user_exists(form.username, module.host) then | 54 local prepped_username = nodeprep(form.username); |
| 54 return nil, "user-exists"; | 55 if usermanager.user_exists(prepped_username, module.host) then |
| 55 end | 56 return nil, "user-exists"; |
| 56 return usermanager.create_user(form.username, form.password, module.host); | 57 end |
| 58 return usermanager.create_user(prepped_username, form.password, module.host); | |
| 57 end | 59 end |
| 58 | 60 |
| 59 function generate_success(event, form) | 61 function generate_success(event, form) |
| 60 return [[<!DOCTYPE html> | 62 return [[<!DOCTYPE html> |
| 61 <html><body><p>Registration succeeded! Your account is <pre>]] | 63 <html><body><p>Registration succeeded! Your account is <pre>]] |