Diff

plugins/mod_legacyauth.lua @ 1831:ced7a6b8bcd0

mod_legacyauth: Added node and resource prepping.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 27 Sep 2009 15:21:08 +0500
parent 1523:841d61be198f
child 1832:a805e4fe104a
line wrap: on
line diff
--- a/plugins/mod_legacyauth.lua	Fri Sep 25 01:35:46 2009 +0100
+++ b/plugins/mod_legacyauth.lua	Sun Sep 27 15:21:08 2009 +0500
@@ -16,6 +16,8 @@
 
 local sessionmanager = require "core.sessionmanager";
 local usermanager = require "core.usermanager";
+local nodeprep = require "util.encodings".stringprep.nodeprep;
+local resourceprep = require "util.encodings".stringprep.resourceprep;
 
 module:add_feature("jabber:iq:auth");
 module:add_event_hook("stream-features", function (session, features)
@@ -46,9 +48,11 @@
 				return true;			
 			else
 				username, password, resource = t_concat(username), t_concat(password), t_concat(resource);
+				username = nodeprep(username);
+				resource = resourceprep(resource)
 				local reply = st.reply(stanza);
 				require "core.usermanager"
-				if usermanager.validate_credentials(session.host, username, password) then
+				if username and usermanager.validate_credentials(session.host, username, password) then
 					-- Authentication successful!
 					local success, err = sessionmanager.make_authenticated(session, username);
 					if success then