Helper methods for hardware colorization (#5870)
[oweals/minetest.git] / builtin / game / auth.lua
index 46fe3d342778c50e15dac1d681ac7929a543a45d..7a6be8788a81231699e8590bda58366b1452c154 100644 (file)
@@ -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 = {}
 
@@ -106,7 +81,7 @@ core.builtin_auth_handler = {
                                end
                        end
                -- For the admin, give everything
-               elseif name == core.setting_get("name") then
+               elseif name == core.settings:get("name") then
                        for priv, def in pairs(core.registered_privileges) do
                                privileges[priv] = true
                        end
@@ -125,7 +100,7 @@ core.builtin_auth_handler = {
                core.log('info', "Built-in authentication handler adding player '"..name.."'")
                core.auth_table[name] = {
                        password = password,
-                       privileges = core.string_to_privs(core.setting_get("default_privs")),
+                       privileges = core.string_to_privs(core.settings:get("default_privs")),
                        last_login = os.time(),
                }
                save_auth_file()
@@ -148,7 +123,7 @@ core.builtin_auth_handler = {
                if not core.auth_table[name] then
                        core.builtin_auth_handler.create_auth(name,
                                core.get_password_hash(name,
-                                       core.setting_get("default_password")))
+                                       core.settings:get("default_password")))
                end
                core.auth_table[name].privileges = privileges
                core.notify_authentication_modified(name)