diff options
Diffstat (limited to 'acf2/model/permission.lua')
-rw-r--r-- | acf2/model/permission.lua | 7 |
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 |