diff --git a/luascripts/wolfadmin/auth/acl.lua b/luascripts/wolfadmin/auth/acl.lua index 8bde24c..e6722a2 100644 --- a/luascripts/wolfadmin/auth/acl.lua +++ b/luascripts/wolfadmin/auth/acl.lua @@ -126,7 +126,7 @@ end function acl.copyLevelPermissions(levelId, newLevelId) db.copyLevelPermissions(levelId, newLevelId) - cachedLevels[newLevelId] = tables.copy(cachedLevels[levelId]) + cachedLevels[newLevelId] = tables.merge(cachedLevels[newLevelId], cachedLevels[levelId]) end function acl.removeLevelPermissions(levelId) diff --git a/luascripts/wolfadmin/util/tables.lua b/luascripts/wolfadmin/util/tables.lua index 6180d88..fba33b2 100644 --- a/luascripts/wolfadmin/util/tables.lua +++ b/luascripts/wolfadmin/util/tables.lua @@ -19,8 +19,19 @@ local util = wolfa_requireModule("util.util") local tables = {} +function tables.merge(tbl1, tbl2) + util.typecheck("tables.merge", {tbl1}, {"table"}) + util.typecheck("tables.merge", {tbl2}, {"table"}) + + for key, value in pairs(tbl2) do + tbl1[key] = value + end + + return tbl1 +end + function tables.copy(tbl) - util.typecheck("tables.contains", {tbl}, {"table"}) + util.typecheck("tables.copy", {tbl}, {"table"}) local copy = {}