Merge pull request #155 from alliedmodders/onclientauth-steam2

Make OnClientAuthorized use Steam2 ids where available (r=asherkin).
This commit is contained in:
Nicholas Hastings 2014-09-11 13:02:28 -04:00
commit 7f0b163b31
4 changed files with 20 additions and 12 deletions

View File

@ -422,6 +422,8 @@ void PlayerManager::RunAuthChecks()
unsigned int client = m_AuthQueue[i];
m_AuthQueue[i] = 0;
removed++;
const char *steamId = pPlayer->GetSteam2Id();
/* Send to extensions */
List<IClientListener *>::iterator iter;
@ -429,7 +431,7 @@ void PlayerManager::RunAuthChecks()
for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
{
pListener = (*iter);
pListener->OnClientAuthorized(client, authstr);
pListener->OnClientAuthorized(client, steamId ? steamId : authstr);
if (!pPlayer->IsConnected())
{
break;
@ -441,7 +443,8 @@ void PlayerManager::RunAuthChecks()
{
/* :TODO: handle the case of a player disconnecting in the middle */
m_clauth->PushCell(client);
m_clauth->PushString(authstr);
/* For legacy reasons, people are expecting the Steam2 id here if using Steam auth */
m_clauth->PushString(steamId ? steamId : authstr);
m_clauth->Execute(NULL);
}
@ -707,18 +710,21 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
cell_t res;
m_clconnect_post->PushCell(client);
m_clconnect_post->Execute(&res, NULL);
const char *steamId = pPlayer->GetSteam2Id();
/* Now do authorization */
for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
{
pListener = (*iter);
pListener->OnClientAuthorized(client, pPlayer->m_AuthID.c_str());
pListener->OnClientAuthorized(client, steamId ? steamId : pPlayer->m_AuthID.c_str());
}
/* Finally, tell plugins */
if (m_clauth->GetFunctionCount())
{
m_clauth->PushCell(client);
m_clauth->PushString(pPlayer->m_AuthID.c_str());
/* For legacy reasons, people are expecting the Steam2 id here if using Steam auth */
m_clauth->PushString(steamId ? steamId : pPlayer->m_AuthID.c_str());
m_clauth->Execute(NULL);
}
pPlayer->Authorize_Post();
@ -2151,7 +2157,7 @@ const CSteamID &CPlayer::GetSteamId(bool validated)
const char *CPlayer::GetSteam2Id(bool validated)
{
if (validated && !IsAuthStringValidated())
if (!m_Steam2Id.length() || (validated && !IsAuthStringValidated()))
{
return NULL;
}
@ -2161,7 +2167,7 @@ const char *CPlayer::GetSteam2Id(bool validated)
const char *CPlayer::GetSteam3Id(bool validated)
{
if (validated && !IsAuthStringValidated())
if (!m_Steam2Id.length() || (validated && !IsAuthStringValidated()))
{
return NULL;
}

View File

@ -394,7 +394,9 @@ void ClientPrefs::CatchLateLoadClients()
continue;
}
g_CookieManager.OnClientAuthorized(i, pPlayer->GetAuthString());
/* For legacy reasons, OnClientAuthorized gives the Steam2 id here if using Steam auth */
const char *steamId = pPlayer->GetSteam2Id();
g_CookieManager.OnClientAuthorized(i, steamId ? steamId : pPlayer->GetAuthString());
}
}

View File

@ -154,14 +154,14 @@ forward Action:OnClientCommand(client, args);
forward void OnClientSettingsChanged(client);
/**
* Called when a client receives a Steam ID. The state of a client's
* Called when a client receives an auth ID. The state of a client's
* authorization as an admin is not guaranteed here. Use
* OnClientPostAdminCheck() if you need a client's admin status.
*
* This is called by bots, but the ID will be "BOT".
*
* @param client Client index.
* @param auth Client auth string.
* @param auth Client Steam2 id, if available, else engine auth id.
* @noreturn
*/
forward void OnClientAuthorized(client, const String:auth[]);

View File

@ -282,7 +282,7 @@ namespace SourceMod
*
* @param validated Check backend validation status.
*
* @return True on success or false if not available.
* @return Steam2 Id on success or NULL if not available.
*/
virtual const char *GetSteam2Id(bool validated = true) =0;
@ -291,7 +291,7 @@ namespace SourceMod
*
* @param validated Check backend validation status.
*
* @return True on success or false if not available.
* @return Steam3 Id on success or NULL if not available.
*/
virtual const char *GetSteam3Id(bool validated = true) =0;
};
@ -365,7 +365,7 @@ namespace SourceMod
* @brief Called when a client has received authorization.
*
* @param client Index of the client.
* @param authstring Authorization string.
* @param authstring Client Steam2 id, if available, else engine auth id.
*/
virtual void OnClientAuthorized(int client, const char *authstring)
{