X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=builtin%2Fgame%2Fauth.lua;h=46fe3d342778c50e15dac1d681ac7929a543a45d;hb=a1346c916e1d0f0cde2ccecc680857896c717a3d;hp=baeb0159c99227f307b53722bd1ebc11d66461e5;hpb=90b6de173ed1321e721599fcfd322b4ba616427f;p=minetest.git diff --git a/builtin/game/auth.lua b/builtin/game/auth.lua index baeb0159c..46fe3d342 100644 --- a/builtin/game/auth.lua +++ b/builtin/game/auth.lua @@ -7,7 +7,7 @@ function core.string_to_privs(str, delim) assert(type(str) == "string") delim = delim or ',' - privs = {} + local privs = {} for _, priv in pairs(string.split(str, delim)) do privs[priv:trim()] = true end @@ -17,10 +17,10 @@ end function core.privs_to_string(privs, delim) assert(type(privs) == "table") delim = delim or ',' - list = {} + local list = {} for priv, bool in pairs(privs) do if bool then - table.insert(list, priv) + list[#list + 1] = priv end end return table.concat(list, delim) @@ -171,6 +171,7 @@ function core.register_authentication_handler(handler) end core.registered_auth_handler = handler core.registered_auth_handler_modname = core.get_current_modname() + handler.mod_origin = core.registered_auth_handler_modname end function core.get_auth_handler() @@ -198,3 +199,19 @@ core.register_on_joinplayer(function(player) record_login(player:get_player_name()) end) +core.register_on_prejoinplayer(function(name, ip) + local auth = core.auth_table + if auth[name] ~= nil then + return + end + + local name_lower = name:lower() + for k in pairs(auth) do + if k:lower() == name_lower then + return string.format("\nCannot create new player called '%s'. ".. + "Another account called '%s' is already registered. ".. + "Please check the spelling if it's your account ".. + "or use a different nickname.", name, k) + end + end +end)