diff mod_auth_sql/mod_auth_sql.lua @ 843:cdc67f4efde2

mod_auth_sql: Add users iterator
author Kim Alvefur <zash@zash.se>
date Fri, 05 Oct 2012 19:34:53 +0200
parents 881ec9919144
children 490cb9161c81
line wrap: on
line diff
--- a/mod_auth_sql/mod_auth_sql.lua	Fri Oct 05 16:57:34 2012 +0200
+++ b/mod_auth_sql/mod_auth_sql.lua	Fri Oct 05 19:34:53 2012 +0200
@@ -114,4 +114,18 @@
 	return new_sasl(module.host, profile);
 end
 
+function provider.users()
+	local stmt, err = getsql("SELECT `username` FROM `authreg` WHERE `realm`=?", module.host);
+	if stmt then
+		local next, state = stmt:rows(true)
+		return function()
+			for row in next, state do
+				return row.username;
+			end
+		end
+	end
+	return stmt, err;
+end
+
+
 module:provides("auth", provider);