summaryrefslogtreecommitdiffstats
path: root/aconf/model/permission.lua
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-03-10 22:45:18 +0200
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-03-24 01:18:13 +0200
commit7d9c43916b0600ac4879dfe9793eab807a83ab2b (patch)
treeec54ed64c9a557b6ea4ad88d31138a02d3e0cd04 /aconf/model/permission.lua
parentcb6c243dc356ef1d46d7ddb96e6ea6ae007c6cca (diff)
downloadaconf-7d9c43916b0600ac4879dfe9793eab807a83ab2b.tar.bz2
aconf-7d9c43916b0600ac4879dfe9793eab807a83ab2b.tar.xz
rename ACF2 to Alpine Configurator (aconf)
Diffstat (limited to 'aconf/model/permission.lua')
-rw-r--r--aconf/model/permission.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/aconf/model/permission.lua b/aconf/model/permission.lua
new file mode 100644
index 0000000..e90099b
--- /dev/null
+++ b/aconf/model/permission.lua
@@ -0,0 +1,25 @@
+--[[
+Copyright (c) 2012-2014 Kaarle Ritvanen
+See LICENSE file for license details
+--]]
+
+local M = {}
+
+local node = require('aconf.model.node')
+local start_txn = require('aconf.transaction')
+
+function M.define(path, ...)
+ local txn = start_txn()
+ local db = txn:fetch('/auth/permissions')
+ for _, permission in ipairs{...} do node.insert(db, permission..path) end
+ txn:commit()
+end
+
+function M.defaults(path)
+ M.define(path, 'read', 'create', 'modify', 'delete')
+ for _, action in ipairs(node.meta(start_txn():fetch(path)).actions or {}) do
+ M.define(path, action.name)
+ end
+end
+
+return M