mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #1053
1053: Don't log out on `sv_rcon{,_mod,_helper}_password` if not changed r=Learath2 a=heinrich5991
This commit is contained in:
commit
10b60008cc
|
@ -2610,25 +2610,30 @@ void CServer::LogoutKey(int Key, const char *pReason)
|
|||
LogoutClient(i, pReason);
|
||||
}
|
||||
|
||||
void CServer::ConchainRconPasswordChangeGeneric(int Level, IConsole::IResult *pResult)
|
||||
void CServer::ConchainRconPasswordChangeGeneric(int Level, const char *pCurrent, IConsole::IResult *pResult)
|
||||
{
|
||||
if(pResult->NumArguments() == 1)
|
||||
{
|
||||
int KeySlot = m_AuthManager.DefaultKey(Level);
|
||||
if(KeySlot == -1 && pResult->GetString(0)[0])
|
||||
const char *pNew = pResult->GetString(0);
|
||||
if(str_comp(pCurrent, pNew) == 0)
|
||||
{
|
||||
m_AuthManager.AddDefaultKey(Level, pResult->GetString(0));
|
||||
return;
|
||||
}
|
||||
if(KeySlot == -1 && pNew[0])
|
||||
{
|
||||
m_AuthManager.AddDefaultKey(Level, pNew);
|
||||
}
|
||||
else if(KeySlot >= 0)
|
||||
{
|
||||
if(!pResult->GetString(0)[0])
|
||||
if(!pNew[0])
|
||||
{
|
||||
AuthRemoveKey(KeySlot);
|
||||
// Already logs users out.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AuthManager.UpdateKey(KeySlot, pResult->GetString(0), Level);
|
||||
m_AuthManager.UpdateKey(KeySlot, pNew, Level);
|
||||
LogoutKey(KeySlot, "key update");
|
||||
}
|
||||
}
|
||||
|
@ -2637,20 +2642,20 @@ void CServer::ConchainRconPasswordChangeGeneric(int Level, IConsole::IResult *pR
|
|||
|
||||
void CServer::ConchainRconPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
||||
{
|
||||
((CServer *)pUserData)->ConchainRconPasswordChangeGeneric(AUTHED_ADMIN, g_Config.m_SvRconPassword, pResult);
|
||||
pfnCallback(pResult, pCallbackUserData);
|
||||
((CServer *)pUserData)->ConchainRconPasswordChangeGeneric(AUTHED_ADMIN, pResult);
|
||||
}
|
||||
|
||||
void CServer::ConchainRconModPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
||||
{
|
||||
((CServer *)pUserData)->ConchainRconPasswordChangeGeneric(AUTHED_MOD, g_Config.m_SvRconModPassword, pResult);
|
||||
pfnCallback(pResult, pCallbackUserData);
|
||||
((CServer *)pUserData)->ConchainRconPasswordChangeGeneric(AUTHED_MOD, pResult);
|
||||
}
|
||||
|
||||
void CServer::ConchainRconHelperPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
||||
{
|
||||
((CServer *)pUserData)->ConchainRconPasswordChangeGeneric(AUTHED_HELPER, g_Config.m_SvRconHelperPassword, pResult);
|
||||
pfnCallback(pResult, pCallbackUserData);
|
||||
((CServer *)pUserData)->ConchainRconPasswordChangeGeneric(AUTHED_HELPER, pResult);
|
||||
}
|
||||
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
|
|
|
@ -326,7 +326,7 @@ public:
|
|||
void LogoutClient(int ClientID, const char *pReason);
|
||||
void LogoutKey(int Key, const char *pReason);
|
||||
|
||||
void ConchainRconPasswordChangeGeneric(int Level, IConsole::IResult *pResult);
|
||||
void ConchainRconPasswordChangeGeneric(int Level, const char *pCurrent, IConsole::IResult *pResult);
|
||||
static void ConchainRconPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
static void ConchainRconModPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
static void ConchainRconHelperPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
|
|
Loading…
Reference in a new issue