# HG changeset patch # User Kim Alvefur # Date 1349458493 -7200 # Node ID cdc67f4efde21865553249c5e2953ea697838fa7 # Parent 32df4d13f1789134253e39058c4ddab983bc21c7 mod_auth_sql: Add users iterator diff -r 32df4d13f178 -r cdc67f4efde2 mod_auth_sql/mod_auth_sql.lua --- 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);