summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-10-14 18:27:00 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-10-14 19:49:57 +0300
commite4c574f68ca5e091ada39a6009ac8095118c5317 (patch)
tree5e7350aeeae0973f6df0ba54c8c721965c526981
parente55dc995617a19fbc5772d7bd9fb3082a2d2b1f4 (diff)
downloadaconf-e4c574f68ca5e091ada39a6009ac8095118c5317.tar.bz2
aconf-e4c574f68ca5e091ada39a6009ac8095118c5317.tar.xz
model: create permission for each action
-rw-r--r--acf2/model/permission.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/acf2/model/permission.lua b/acf2/model/permission.lua
index 71fa1a5..9911ba0 100644
--- a/acf2/model/permission.lua
+++ b/acf2/model/permission.lua
@@ -5,18 +5,21 @@ See LICENSE file for license details
local M = {}
-local insert = require('acf2.model.node').insert
+local node = require('acf2.model.node')
local start_txn = require('acf2.transaction')
function M.define(path, ...)
local txn = start_txn()
local db = txn:fetch('/auth/permissions')
- for _, permission in ipairs{...} do insert(db, permission..path) end
+ 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