summaryrefslogtreecommitdiffstats
path: root/authenticator-freeswitch-vmail.lua
diff options
context:
space:
mode:
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