Browse Source

Fixed authorization pass with admin flag checks

A few fixes:  (1) Use `OnClientPostAdminCheck` so we can use SourceMod's
access overrides in determining if we should query the CBL, and (2) Fix
`CheckCommandAccess` to only whitelist root-level admins by default.
nosoop 6 years ago
parent
commit
5dcbb08802
1 changed files with 6 additions and 4 deletions
  1. 6 4
      scripting/source_cbl.sp

+ 6 - 4
scripting/source_cbl.sp

@@ -9,7 +9,7 @@
 #pragma newdecls required
 #include "source_cbl/webapi.sp"
 
-#define PLUGIN_VERSION "0.2.0"
+#define PLUGIN_VERSION "0.2.1"
 public Plugin myinfo = {
 	name = "[CSRD] SourceCBL Integration",
 	author = "nosoop",
@@ -33,13 +33,15 @@ public void OnPluginStart() {
 	char portString[6];
 	IntToString(port, portString, sizeof(portString));
 	
-	
 	RegAdminCmd("cbl_check_steamid", CheckCBLStatus, ADMFLAG_ROOT);
 	
 	BuildPath(Path_SM, g_CommunityKickLog, sizeof(g_CommunityKickLog), "logs/sourcecbl.log");
 }
 
-public void OnClientAuthorized(int client) {
+/**
+ * Called once authorized and SourceMod is able to check the client's admin flags.
+ */
+public void OnClientPostAdminCheck(int client) {
 	if (!IsFakeClient(client) && !SkipCommunityBanListCheck(client)) {
 		RequestClientBanStatus(client);
 	}
@@ -47,7 +49,7 @@ public void OnClientAuthorized(int client) {
 
 bool SkipCommunityBanListCheck(int client) {
 	// TODO check if account is whitelisted (command group / keyvalues / clientprefs cache, etc.)
-	return CheckCommandAccess(client, "cbl_whitelist", 0);
+	return CheckCommandAccess(client, "cbl_whitelist", ADMFLAG_ROOT);
 }
 
 void RequestClientBanStatus(int client) {