aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api
diff options
context:
space:
mode:
authorred-001 <red-001@outlook.ie>2018-02-15 20:18:54 +0000
committerSmallJoker <SmallJoker@users.noreply.github.com>2018-02-15 21:18:54 +0100
commit338d645fcfa1f07a82c4940aa09a6fb265ff608f (patch)
treec2665c7108e84f677fc20ae2f8d90984fcd8532f /src/script/cpp_api
parent861cfd848473db6c36b0debb7152d98ca8017062 (diff)
downloadminetest-338d645fcfa1f07a82c4940aa09a6fb265ff608f.tar.gz
minetest-338d645fcfa1f07a82c4940aa09a6fb265ff608f.tar.bz2
minetest-338d645fcfa1f07a82c4940aa09a6fb265ff608f.zip
Add `on_auth_fail` callback (#7039)
Called when a client fails to supply the correct password for the account it's attempting to login as.
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r--src/script/cpp_api/s_player.cpp11
-rw-r--r--src/script/cpp_api/s_player.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/script/cpp_api/s_player.cpp b/src/script/cpp_api/s_player.cpp
index f3c316650..578298e24 100644
--- a/src/script/cpp_api/s_player.cpp
+++ b/src/script/cpp_api/s_player.cpp
@@ -206,3 +206,14 @@ void ScriptApiPlayer::on_playerReceiveFields(ServerActiveObject *player,
runCallbacks(3, RUN_CALLBACKS_MODE_OR_SC);
}
+void ScriptApiPlayer::on_auth_failure(const std::string &name, const std::string &ip)
+{
+ SCRIPTAPI_PRECHECKHEADER
+
+ // Get core.registered_on_auth_failure
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_auth_fail");
+ lua_pushstring(L, name.c_str());
+ lua_pushstring(L, ip.c_str());
+ runCallbacks(2, RUN_CALLBACKS_MODE_FIRST);
+}
diff --git a/src/script/cpp_api/s_player.h b/src/script/cpp_api/s_player.h
index 6b752eb69..562805695 100644
--- a/src/script/cpp_api/s_player.h
+++ b/src/script/cpp_api/s_player.h
@@ -45,4 +45,5 @@ public:
s16 on_player_hpchange(ServerActiveObject *player, s16 hp_change);
void on_playerReceiveFields(ServerActiveObject *player,
const std::string &formname, const StringMap &fields);
+ void on_auth_failure(const std::string &name, const std::string &ip);
};