comparison mod_register_web/mod_register_web.lua @ 746:03595194075a

mod_register_web: nodeprep username before creating user (thanks IRON)
author Matthew Wild <mwild1@gmail.com>
date Sun, 22 Jul 2012 19:52:45 +0100
parents c08b0e4b7b38
children b9d149936764
comparison
equal deleted inserted replaced
745:c68ce6eb97f0 746:03595194075a
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>]]