MCPcopy Create free account
hub / github.com/ddnet/ddnet / ConAuthAdd

Method ConAuthAdd

src/engine/server/server.cpp:3621–3654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3619}
3620
3621void CServer::ConAuthAdd(IConsole::IResult *pResult, void *pUser)
3622{
3623 CServer *pThis = (CServer *)pUser;
3624 CAuthManager *pManager = &pThis->m_AuthManager;
3625
3626 const char *pIdent = pResult->GetString(0);
3627 const char *pLevel = pResult->GetString(1);
3628 const char *pPw = pResult->GetString(2);
3629
3630 if(!pManager->IsValidIdent(pIdent))
3631 {
3632 pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "auth", "ident is invalid");
3633 return;
3634 }
3635
3636 int Level = GetAuthLevel(pLevel);
3637 if(Level == -1)
3638 {
3639 pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "auth", "level can be one of {\"admin\", \"mod(erator)\", \"helper\"}");
3640 return;
3641 }
3642 // back compat to change "mod", "modder" and so on as parameters to "moderator"
3643 pLevel = CAuthManager::AuthLevelToRoleName(Level);
3644
3645 bool NeedUpdate = !pManager->NumNonDefaultKeys();
3646 if(pManager->AddKey(pIdent, pPw, pLevel) < 0)
3647 pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "auth", "ident already exists");
3648 else
3649 {
3650 if(NeedUpdate)
3651 pThis->SendRconType(-1, true);
3652 pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "auth", "key added");
3653 }
3654}
3655
3656void CServer::ConAuthAddHashed(IConsole::IResult *pResult, void *pUser)
3657{

Callers

nothing calls this directly

Calls 8

GetAuthLevelFunction · 0.85
IsValidIdentMethod · 0.80
NumNonDefaultKeysMethod · 0.80
AddKeyMethod · 0.80
SendRconTypeMethod · 0.80
GetStringMethod · 0.45
PrintMethod · 0.45
ConsoleMethod · 0.45

Tested by

no test coverage detected