comparison mod_register_web/mod_register_web.lua @ 1236:59332e0bfbdc

mod_register_web: Check for empty username
author Kim Alvefur <zash@zash.se>
date Sat, 30 Nov 2013 23:36:41 +0100
parents 9277e0a3922f
children c669cb78b293
comparison
equal deleted inserted replaced
1235:9277e0a3922f 1236:59332e0bfbdc
109 function register_user(form) 109 function register_user(form)
110 local prepped_username = nodeprep(form.username); 110 local prepped_username = nodeprep(form.username);
111 if not prepped_username then 111 if not prepped_username then
112 return nil, "Username contains forbidden characters"; 112 return nil, "Username contains forbidden characters";
113 end 113 end
114 if #prepped_username == 0 then
115 return nil, "The username field was empty";
116 end
114 if usermanager.user_exists(prepped_username, module.host) then 117 if usermanager.user_exists(prepped_username, module.host) then
115 return nil, "Username already taken"; 118 return nil, "Username already taken";
116 end 119 end
117 local ok, err = usermanager.create_user(prepped_username, form.password, module.host); 120 local ok, err = usermanager.create_user(prepped_username, form.password, module.host);
118 if ok then 121 if ok then