Don't grant priveleges to non-existent players.
author0gb.us <0gb.us@0gb.us>
Sat, 30 Mar 2013 08:51:41 +0000 (01:51 -0700)
committerkwolekr <kwolekr@minetest.net>
Sun, 31 Mar 2013 01:50:07 +0000 (21:50 -0400)
When accidentally misspelling a name, privileges are sometimes granted to non-existent players, leaving them with the extra privileges, but without the default privileges, if they ever join the server. This corrects that by disallowing /grant from working with invalid players. For completeness, it does the same for /revoke.

builtin/chatcommands.lua

index f41f9afe43a33d44c001e6d26ecbc7c98f3cba8c..4b09f7b2bee3b44813e74af9afe6917d8abf5d21 100644 (file)
@@ -116,6 +116,9 @@ minetest.register_chatcommand("grant", {
                if not grantname or not grantprivstr then
                        minetest.chat_send_player(name, "Invalid parameters (see /help grant)")
                        return
+               elseif not minetest.auth_table[grantname] then
+                       minetest.chat_send_player(name, "Player "..grantname.." does not exist.")
+                       return
                end
                local grantprivs = minetest.string_to_privs(grantprivstr)
                if grantprivstr == "all" then
@@ -159,6 +162,9 @@ minetest.register_chatcommand("revoke", {
                if not revokename or not revokeprivstr then
                        minetest.chat_send_player(name, "Invalid parameters (see /help revoke)")
                        return
+               elseif not minetest.auth_table[revokename] then
+                       minetest.chat_send_player(name, "Player "..revokename.." does not exist.")
+                       return
                end
                local revokeprivs = minetest.string_to_privs(revokeprivstr)
                local privs = minetest.get_player_privs(revokename)