mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
[CSM] Add function to get player privileges (#5933)
* [CSM] Add function to get player privileges + move related help functions to common * Added @Zeno- const
This commit is contained in:
parent
6c55874417
commit
c91a8c7061
7 changed files with 56 additions and 25 deletions
|
@ -4,31 +4,6 @@
|
|||
-- Authentication handler
|
||||
--
|
||||
|
||||
function core.string_to_privs(str, delim)
|
||||
assert(type(str) == "string")
|
||||
delim = delim or ','
|
||||
local privs = {}
|
||||
for _, priv in pairs(string.split(str, delim)) do
|
||||
privs[priv:trim()] = true
|
||||
end
|
||||
return privs
|
||||
end
|
||||
|
||||
function core.privs_to_string(privs, delim)
|
||||
assert(type(privs) == "table")
|
||||
delim = delim or ','
|
||||
local list = {}
|
||||
for priv, bool in pairs(privs) do
|
||||
if bool then
|
||||
list[#list + 1] = priv
|
||||
end
|
||||
end
|
||||
return table.concat(list, delim)
|
||||
end
|
||||
|
||||
assert(core.string_to_privs("a,b").b == true)
|
||||
assert(core.privs_to_string({a=true,b=true}) == "a,b")
|
||||
|
||||
core.auth_file_path = core.get_worldpath().."/auth.txt"
|
||||
core.auth_table = {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue