Diff

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
parent 653:c08b0e4b7b38
child 791:b9d149936764
line wrap: on
line diff
--- a/mod_register_web/mod_register_web.lua	Thu Jul 19 15:33:35 2012 +0100
+++ b/mod_register_web/mod_register_web.lua	Sun Jul 22 19:52:45 2012 +0100
@@ -1,4 +1,5 @@
 local captcha_options = module:get_option("captcha_options", {});
+local nodeprep = require "util.encodings".stringprep.nodeprep;
 
 function generate_captcha(display_options)
 	return (([[
@@ -50,10 +51,11 @@
 end
 
 function register_user(form)
-	if usermanager.user_exists(form.username, module.host) then
-		return nil, "user-exists";
-	end
-	return usermanager.create_user(form.username, form.password, module.host);
+        local prepped_username = nodeprep(form.username);
+        if usermanager.user_exists(prepped_username, module.host) then
+                return nil, "user-exists";
+        end
+        return usermanager.create_user(prepped_username, form.password, module.host);
 end
 
 function generate_success(event, form)