summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
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 %>