| 3619 | } |
| 3620 | |
| 3621 | void 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 | |
| 3656 | void CServer::ConAuthAddHashed(IConsole::IResult *pResult, void *pUser) |
| 3657 | { |
nothing calls this directly
no test coverage detected