summaryrefslogtreecommitdiffstats
path: root/authenticator-freeswitch-vmail.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2010-09-28 07:01:07 +0000
committerTed Trask <ttrask01@yahoo.com>2010-09-28 07:01:07 +0000
commit956b5395d1a1292e9e274e90d042556de7f17f86 (patch)
tree5e3033531fda9ec5598039d4f7959c921477b22e /authenticator-freeswitch-vmail.lua
parent002c2df6ed1cbbccc2aec69191829fa1673f4b68 (diff)
downloadacf-freeswitch-vmail-956b5395d1a1292e9e274e90d042556de7f17f86.tar.bz2
acf-freeswitch-vmail-956b5395d1a1292e9e274e90d042556de7f17f86.tar.xz
Several changes to improve speed and efficiency
Added list_passwords function and implemented auth.read_entry to speed up the authenticator library. Modified users, values, and params tables to use integer references, rather than varchar. Made complicated query for list_users, rather than looping in lua. And added some indexes. The changes to schemas breaks backwards compatibility.
Diffstat (limited to 'authenticator-freeswitch-vmail.lua')
-rw-r--r--authenticator-freeswitch-vmail.lua21
1 files changed, 16 insertions, 5 deletions
diff --git a/authenticator-freeswitch-vmail.lua b/authenticator-freeswitch-vmail.lua
index 5824dc7..92aa29d 100644
--- a/authenticator-freeswitch-vmail.lua
+++ b/authenticator-freeswitch-vmail.lua
@@ -14,11 +14,10 @@ read_field = function(self, tabl, field)
if tabl == authenticator.usertable and field == "" then
-- authenticator is reading all users
local vmcontroller = self:new("freeswitch-vmail/vmail")
- local users = vmcontroller:listusers()
+ local users = vmcontroller.model.list_passwords()
for i,val in ipairs(users.value) do
- local settings = vmcontroller.model.get_usersettings(val.username)
- local string = md5.sumhexa(settings.value["vm-password"].value)..":Voicemail User:/freeswitch-vmail/vmail/USER"
- result[#result+1] = { id=settings.value.username.value, entry=string }
+ local string = md5.sumhexa(val.password)..":Voicemail User:/freeswitch-vmail/vmail/USER"
+ result[#result+1] = { id=val.username, entry=string }
end
vmcontroller:destroy()
end
@@ -36,7 +35,19 @@ write_entry = function(self, tabl, field, id, entry)
end
read_entry = function(self, tabl, field, id)
- result = a.read_entry(self, tabl, field, id)
+ local result
+ if tabl == authenticator.usertable and field == "" then
+ -- authenticator is reading one user
+ local vmcontroller = self:new("freeswitch-vmail/vmail")
+ local users = vmcontroller.model.list_passwords(id)
+ if users and users.value and users.value[1] and users.value[1].password then
+ result = md5.sumhexa(users.value[1].password)..":Voicemail User:/freeswitch-vmail/vmail/USER"
+ end
+ vmcontroller:destroy()
+ end
+ if not result then
+ result = a.read_entry(self, tabl, field, id)
+ end
return result
end