Changeset

843:cdc67f4efde2

mod_auth_sql: Add users iterator
author Kim Alvefur <zash@zash.se>
date Fri, 05 Oct 2012 19:34:53 +0200
parents 842:32df4d13f178
children 844:a0987c0e4e1d
files mod_auth_sql/mod_auth_sql.lua
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
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);