Changeset

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 745:c68ce6eb97f0
children 747:e54b92a26d40
files mod_register_web/mod_register_web.lua
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
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)