Auth API: Error when accessed prior to ServerEnv init (#11398)

This commit is contained in:
SmallJoker 2021-06-30 20:42:26 +02:00 committed by GitHub
parent 827a7852e2
commit 062fd2190e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -32,8 +32,11 @@ AuthDatabase *ModApiAuth::getAuthDb(lua_State *L)
{
ServerEnvironment *server_environment =
dynamic_cast<ServerEnvironment *>(getEnv(L));
if (!server_environment)
if (!server_environment) {
luaL_error(L, "Attempt to access an auth function but the auth"
" system is yet not initialized. This causes bugs.");
return nullptr;
}
return server_environment->getAuthDatabase();
}