summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-12-17 10:15:51 +0000
committerTed Trask <ttrask01@yahoo.com>2009-12-17 10:15:51 +0000
commit1b8a047f7d1c71a1efd0bd34b5f887086a857b20 (patch)
tree1c9eb5f130d13f06f76a17d7e0cdce03416bafc0 /app
parentb2b8ac87e45257215fa9642858a3bc5903b160e6 (diff)
downloadacf-core-1b8a047f7d1c71a1efd0bd34b5f887086a857b20.tar.bz2
acf-core-1b8a047f7d1c71a1efd0bd34b5f887086a857b20.tar.xz
Added a check-permission function to viewlibrary to abstract permissions.
Diffstat (limited to 'app')
-rw-r--r--app/acf_www-controller.lua17
-rw-r--r--app/expert-html.lsp2
-rw-r--r--app/status-html.lsp4
3 files changed, 17 insertions, 6 deletions
diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua
index 9e92e0e..e71ba4f 100644
--- a/app/acf_www-controller.lua
+++ b/app/acf_www-controller.lua
@@ -69,6 +69,17 @@ local check_permission = function(self, controller, action)
return true
end
+local check_permission_string = function (self, str)
+ local prefix, controller, action = self.parse_path_info("/" .. (str or ""))
+ if prefix == "/" then prefix = self.conf.prefix end
+ if controller == "" then controller = self.conf.controller end
+
+ if "" == action then
+ action = rawget(self.worker, "default_action") or ""
+ end
+ return check_permission(self, controller, action)
+end
+
-- look for a template
-- ctlr-action-view, then ctlr-view, then action-view, then view
-- cannot be local function because of recursion
@@ -124,9 +135,8 @@ local has_view = function(self)
end
-- This function is made available within the view to allow loading of components
-local dispatch_component = function(str, clientdata, suppress_view)
+local dispatch_component = function(self, str, clientdata, suppress_view)
-- Before we call dispatch, we have to set up conf and clientdata like it was really called for this component
- self = APP
local tempconf = self.conf
self.conf = {}
for x,y in pairs(tempconf) do
@@ -163,7 +173,8 @@ local create_helper_library = function ( self )
end
end
--]]
- library.dispatch_component = dispatch_component
+ library.dispatch_component = function(...) return dispatch_component(self, ...) end
+ library.check_permission = function(...) return check_permission_string(self, ...) end
return library
end
diff --git a/app/expert-html.lsp b/app/expert-html.lsp
index 24213a7..b54ff4e 100644
--- a/app/expert-html.lsp
+++ b/app/expert-html.lsp
@@ -13,6 +13,6 @@ local func = haserl.loadfile(page_info.viewfile:gsub(pattern..".*$", "/") .. "fi
func(form, viewlibrary, page_info, session)
%>
-<% if viewlibrary and viewlibrary.dispatch_component and session.permissions[page_info.controller].startstop then
+<% if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("startstop") then
viewlibrary.dispatch_component("startstop")
end %>
diff --git a/app/status-html.lsp b/app/status-html.lsp
index eb63527..e8f7a15 100644
--- a/app/status-html.lsp
+++ b/app/status-html.lsp
@@ -10,14 +10,14 @@ require("viewfunctions")
displayitem(data.value.status)
displayitem(data.value.version)
-if data.value.version and data.value.version.errtxt and session.permissions.apk and session.permissions.apk.install then
+if data.value.version and data.value.version.errtxt and viewlibrary.check_permission("apk-tools/apk/install") then
%>
<a href="<%= html.html_escape(page_info.script .. "/apk-tools/apk/install?package="..data.value.version.name) %>">Install</a>
<%
end
displayitem(data.value.autostart)
-if not (data.value.version and data.value.version.errtxt) and data.value.autostart and data.value.autostart.errtxt and session.permissions.rc and session.permissions.rc.edit then
+if not (data.value.version and data.value.version.errtxt) and data.value.autostart and data.value.autostart.errtxt and viewlibrary.check_permission("alpine-baselayout/rc/edit") then
%>
<a href="<%= html.html_escape(page_info.script .. "/alpine-baselayout/rc/edit?servicename="..data.value.autostart.name.."&redir=".. page_info.orig_action) %>">Enable autostart</a>
<% end %>