add iterate function to auth handler

auth_table is a local cache so provide a method of returning the full list of names
0.4
shivajiva101 2018-04-05 17:51:41 +01:00 committed by GitHub
parent db5a9705e5
commit 34b4cd1e0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -93,7 +93,7 @@ local function get_setting(column)
return row
end
local function get_names(name)
local function search(name)
local r,q = {}
q = "SELECT name FROM auth WHERE name LIKE '%"..name.."%';"
for row in db:nrows(q) do
@ -102,6 +102,15 @@ local function get_names(name)
return r
end
local function get_names()
local r,q = {}
q = "SELECT name FROM auth;"
for row in db:nrows(q) do
r[row.name] = true
end
return r
end
--[[
##############################
### Database: Statements ###
@ -286,8 +295,11 @@ sauth.auth_handler = {
end,
name_search = function(name)
assert(type(name) == 'string')
return get_names(name)
end
return search(name)
end,
iterate = function()
return get_names()
end,
}
--[[