summaryrefslogtreecommitdiffstats
path: root/tinydns-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2012-10-26 23:54:56 +0000
committerTed Trask <ttrask01@yahoo.com>2012-10-26 23:54:56 +0000
commitdcfd4d636ccb195e943cb0dacfb72acc6cc1d7e1 (patch)
tree27a0d412c59db789aca4f2773419582de2be8695 /tinydns-model.lua
parent36f7647b0898d9ab95789ece72766261352a3d24 (diff)
downloadacf-tinydns-dcfd4d636ccb195e943cb0dacfb72acc6cc1d7e1.tar.bz2
acf-tinydns-dcfd4d636ccb195e943cb0dacfb72acc6cc1d7e1.tar.xz
Use authenticator.get_subauth function rather than public auth variable
Diffstat (limited to 'tinydns-model.lua')
-rw-r--r--tinydns-model.lua22
1 files changed, 14 insertions, 8 deletions
diff --git a/tinydns-model.lua b/tinydns-model.lua
index baf0f8d..9c239c6 100644
--- a/tinydns-model.lua
+++ b/tinydns-model.lua
@@ -106,7 +106,8 @@ end
local function getallowedlist(self, userid)
local allowedlist = {}
- local entry = authenticator.auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid) or ""
+ local auth = authenticator.get_subauth(self)
+ local entry = auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid) or ""
for x in string.gmatch(entry, "([^,]+),?") do allowedlist[#allowedlist + 1] = x end
-- also check to see if there are allowed files for this user's roles
@@ -114,7 +115,7 @@ local function getallowedlist(self, userid)
-- add in the guest role
userinfo.roles[#userinfo.roles + 1] = roles.guest_role
for i,role in ipairs(userinfo.roles) do
- local entry = authenticator.auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
+ local entry = auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
for x in string.gmatch(entry, "([^,]+),?") do allowedlist[#allowedlist + 1] = x end
end
return allowedlist
@@ -339,11 +340,12 @@ function remove_file(self, delfile, userid)
end
function getpermissionslist(self)
+ local auth = authenticator.get_subauth(self)
local users = authenticator.list_users(self)
local userlist = {}
for i,user in ipairs(users) do
local allowedlist = {}
- local entry = authenticator.auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, user) or ""
+ local entry = auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, user) or ""
for x in string.gmatch(entry, "([^,]+),?") do allowedlist[#allowedlist + 1] = x end
userlist[#userlist + 1] = {id=user, allowed=allowedlist}
end
@@ -352,7 +354,7 @@ function getpermissionslist(self)
local rols = roles.list_all_roles(self)
for i,role in ipairs(rols) do
local allowedlist = {}
- local entry = authenticator.auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
+ local entry = auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
for x in string.gmatch(entry, "([^,]+),?") do allowedlist[#allowedlist + 1] = x end
rolelist[#rolelist + 1] = {id=role, allowed=allowedlist}
end
@@ -388,7 +390,8 @@ end
function getuserpermissions(self, userid)
local allowedlist = {}
- local entry = authenticator.auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid) or ""
+ local auth = authenticator.get_subauth(self)
+ local entry = auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid) or ""
for x in string.gmatch(entry, "([^,]+),?") do allowedlist[#allowedlist + 1] = x end
local cnffile = {}
recursedir(configdir, cnffile)
@@ -407,7 +410,8 @@ function setuserpermissions(self, userpermissions)
local success, userpermissions = validateuserpermissions(self, userpermissions)
if success then
- authenticator.auth.write_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userpermissions.value.userid.value, table.concat(userpermissions.value.allowed.value, ","))
+ local auth = authenticator.get_subauth(self)
+ auth.write_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userpermissions.value.userid.value, table.concat(userpermissions.value.allowed.value, ","))
else
userpermissions.errtxt = "Failed to set user permissions"
end
@@ -416,7 +420,8 @@ end
function getrolepermissions(self, role)
local allowedlist = {}
- local entry = authenticator.auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
+ local auth = authenticator.get_subauth(self)
+ local entry = auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
for x in string.gmatch(entry, "([^,]+),?") do allowedlist[#allowedlist + 1] = x end
local cnffile = {}
recursedir(configdir, cnffile)
@@ -435,7 +440,8 @@ function setrolepermissions(self, rolepermissions)
local success, rolepermissions = validaterolepermissions(self, rolepermissions)
if success then
- authenticator.auth.write_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, rolepermissions.value.role.value, table.concat(rolepermissions.value.allowed.value, ","))
+ local auth = authenticator.get_subauth(self)
+ auth.write_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, rolepermissions.value.role.value, table.concat(rolepermissions.value.allowed.value, ","))
else
rolepermissions.errtxt = "Failed to set role permissions"
end