]> git.lizzy.rs Git - minetest.git/blobdiff - builtin/game/chatcommands.lua
Fix /grant & /revoke not working with custom auth handler (#4974)
[minetest.git] / builtin / game / chatcommands.lua
index d8fee1578757926f327bf71877d5644ade3b7d8a..71edeb26a0f5a3431a4d3c6bc6e8cde01d3cddf5 100644 (file)
@@ -147,11 +147,12 @@ core.register_chatcommand("help", {
 core.register_chatcommand("privs", {
        params = "<name>",
        description = "print out privileges of player",
-       func = function(name, param)
-               param = (param ~= "" and param or name)
-               return true, "Privileges of " .. param .. ": "
+       func = function(caller, param)
+               param = param:trim()
+               local name = (param ~= "" and param or caller)
+               return true, "Privileges of " .. name .. ": "
                        .. core.privs_to_string(
-                               core.get_player_privs(param), ' ')
+                               core.get_player_privs(name), ' ')
        end,
 })
 
@@ -161,7 +162,7 @@ local function handle_grant_command(caller, grantname, grantprivstr)
                return false, "Your privileges are insufficient."
        end
        
-       if not core.auth_table[grantname] then
+       if not core.get_auth_handler().get_auth(grantname) then
                return false, "Player " .. grantname .. " does not exist."
        end
        local grantprivs = core.string_to_privs(grantprivstr)
@@ -231,7 +232,7 @@ core.register_chatcommand("revoke", {
                local revoke_name, revoke_priv_str = string.match(param, "([^ ]+) (.+)")
                if not revoke_name or not revoke_priv_str then
                        return false, "Invalid parameters (see /help revoke)"
-               elseif not core.auth_table[revoke_name] then
+               elseif not core.get_auth_handler().get_auth(revoke_name) then
                        return false, "Player " .. revoke_name .. " does not exist."
                end
                local revoke_privs = core.string_to_privs(revoke_priv_str)