aboutsummaryrefslogtreecommitdiff
path: root/builtin/game
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/game')
-rw-r--r--builtin/game/auth.lua3
-rw-r--r--builtin/game/chat.lua2
-rw-r--r--builtin/game/deprecated.lua16
-rw-r--r--builtin/game/register.lua2
4 files changed, 19 insertions, 4 deletions
diff --git a/builtin/game/auth.lua b/builtin/game/auth.lua
index 7aedfc82e..fc061666c 100644
--- a/builtin/game/auth.lua
+++ b/builtin/game/auth.lua
@@ -41,7 +41,6 @@ core.builtin_auth_handler = {
return {
password = auth_entry.password,
privileges = privileges,
- -- Is set to nil if unknown
last_login = auth_entry.last_login,
}
end,
@@ -53,7 +52,7 @@ core.builtin_auth_handler = {
name = name,
password = password,
privileges = core.string_to_privs(core.settings:get("default_privs")),
- last_login = os.time(),
+ last_login = -1, -- Defer login time calculation until record_login (called by on_joinplayer)
})
end,
delete_auth = function(name)
diff --git a/builtin/game/chat.lua b/builtin/game/chat.lua
index b9f84e522..aae811794 100644
--- a/builtin/game/chat.lua
+++ b/builtin/game/chat.lua
@@ -1068,7 +1068,7 @@ core.register_chatcommand("last-login", {
param = name
end
local pauth = core.get_auth_handler().get_auth(param)
- if pauth and pauth.last_login then
+ if pauth and pauth.last_login and pauth.last_login ~= -1 then
-- Time in UTC, ISO 8601 format
return true, "Last login time was " ..
os.date("!%Y-%m-%dT%H:%M:%SZ", pauth.last_login)
diff --git a/builtin/game/deprecated.lua b/builtin/game/deprecated.lua
index 73e105eb8..20f0482eb 100644
--- a/builtin/game/deprecated.lua
+++ b/builtin/game/deprecated.lua
@@ -70,3 +70,19 @@ core.setting_get = setting_proxy("get")
core.setting_setbool = setting_proxy("set_bool")
core.setting_getbool = setting_proxy("get_bool")
core.setting_save = setting_proxy("write")
+
+--
+-- core.register_on_auth_fail
+--
+
+function core.register_on_auth_fail(func)
+ core.log("deprecated", "core.register_on_auth_fail " ..
+ "is obsolete and should be replaced by " ..
+ "core.register_on_authplayer instead.")
+
+ core.register_on_authplayer(function (player_name, ip, is_success)
+ if not is_success then
+ func(player_name, ip)
+ end
+ end)
+end
diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index eb6c2897c..1034d4f2b 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -607,9 +607,9 @@ core.registered_on_item_eats, core.register_on_item_eat = make_registration()
core.registered_on_punchplayers, core.register_on_punchplayer = make_registration()
core.registered_on_priv_grant, core.register_on_priv_grant = make_registration()
core.registered_on_priv_revoke, core.register_on_priv_revoke = make_registration()
+core.registered_on_authplayers, core.register_on_authplayer = make_registration()
core.registered_can_bypass_userlimit, core.register_can_bypass_userlimit = make_registration()
core.registered_on_modchannel_message, core.register_on_modchannel_message = make_registration()
-core.registered_on_auth_fail, core.register_on_auth_fail = make_registration()
core.registered_on_player_inventory_actions, core.register_on_player_inventory_action = make_registration()
core.registered_allow_player_inventory_actions, core.register_allow_player_inventory_action = make_registration()