Add on_authplayer callback and 'last_login' to on_joinplayer (#9574)
Replace on_auth_fail callback with more versatile on_authplayer Better clarify account login process in Lua API documentation Change initial timestamp for newly registered accounts to -1
This commit is contained in:
parent
976af00e17
commit
83782c6080
|
@ -41,7 +41,6 @@ core.builtin_auth_handler = {
|
||||||
return {
|
return {
|
||||||
password = auth_entry.password,
|
password = auth_entry.password,
|
||||||
privileges = privileges,
|
privileges = privileges,
|
||||||
-- Is set to nil if unknown
|
|
||||||
last_login = auth_entry.last_login,
|
last_login = auth_entry.last_login,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
@ -53,7 +52,7 @@ core.builtin_auth_handler = {
|
||||||
name = name,
|
name = name,
|
||||||
password = password,
|
password = password,
|
||||||
privileges = core.string_to_privs(core.settings:get("default_privs")),
|
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,
|
end,
|
||||||
delete_auth = function(name)
|
delete_auth = function(name)
|
||||||
|
|
|
@ -1068,7 +1068,7 @@ core.register_chatcommand("last-login", {
|
||||||
param = name
|
param = name
|
||||||
end
|
end
|
||||||
local pauth = core.get_auth_handler().get_auth(param)
|
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
|
-- Time in UTC, ISO 8601 format
|
||||||
return true, "Last login time was " ..
|
return true, "Last login time was " ..
|
||||||
os.date("!%Y-%m-%dT%H:%M:%SZ", pauth.last_login)
|
os.date("!%Y-%m-%dT%H:%M:%SZ", pauth.last_login)
|
||||||
|
|
|
@ -70,3 +70,19 @@ core.setting_get = setting_proxy("get")
|
||||||
core.setting_setbool = setting_proxy("set_bool")
|
core.setting_setbool = setting_proxy("set_bool")
|
||||||
core.setting_getbool = setting_proxy("get_bool")
|
core.setting_getbool = setting_proxy("get_bool")
|
||||||
core.setting_save = setting_proxy("write")
|
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
|
||||||
|
|
|
@ -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_punchplayers, core.register_on_punchplayer = make_registration()
|
||||||
core.registered_on_priv_grant, core.register_on_priv_grant = 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_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_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_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_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()
|
core.registered_allow_player_inventory_actions, core.register_allow_player_inventory_action = make_registration()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue