comparison mod_register_web/mod_register_web.lua @ 1232:12f59489ef6e

mod_register_web: Fire user-registered event
author Kim Alvefur <zash@zash.se>
date Sat, 30 Nov 2013 20:29:49 +0100
parents 502ce9672eae
children f7b1992e4ff6
comparison
equal deleted inserted replaced
1231:502ce9672eae 1232:12f59489ef6e
106 return nil, "Username contains forbidden characters"; 106 return nil, "Username contains forbidden characters";
107 end 107 end
108 if usermanager.user_exists(prepped_username, module.host) then 108 if usermanager.user_exists(prepped_username, module.host) then
109 return nil, "Username already taken"; 109 return nil, "Username already taken";
110 end 110 end
111 return usermanager.create_user(prepped_username, form.password, module.host); 111 local ok, err usermanager.create_user(prepped_username, form.password, module.host);
112 if ok then
113 module:fire_event("user-registered", {
114 username = prepped_username,
115 host = module.host,
116 source = module.name
117 });
118 end
119 return ok, err;
112 end 120 end
113 121
114 function generate_success(event, form) 122 function generate_success(event, form)
115 return render(success_tpl, { jid = nodeprep(form.username).."@"..module.host }); 123 return render(success_tpl, { jid = nodeprep(form.username).."@"..module.host });
116 end 124 end