Skip to content

Commit 1ccd712

Browse files
author
Bill Chirico
committed
fix: resolve merge conflicts and remove debug code
1 parent c5b09eb commit 1ccd712

4 files changed

Lines changed: 5 additions & 19 deletions

File tree

node_modules

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/api/middleware/requireGlobalAdmin.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,36 @@
1+
import { warn } from '../../logger.js';
12
import { getConfig } from '../../modules/config.js';
23
import { getBotOwnerIds } from '../../utils/permissions.js';
3-
import { warn } from '../../logger.js';
44

55
/**
66
* Middleware: restrict to API-secret callers or bot-owner OAuth users.
77
*/
88
export function requireGlobalAdmin(forResource, req, res, next) {
9-
console.error('[DEBUG] requireGlobalAdmin called');
10-
console.error('[DEBUG] arguments.length:', arguments.length);
11-
console.error('[DEBUG] typeof forResource:', typeof forResource);
12-
139
// Support both requireGlobalAdmin(req, res, next) and requireGlobalAdmin('Resource', req, res, next)
1410
if (arguments.length === 3) {
15-
console.error('[DEBUG] 3-arg case: shifting parameters');
1611
// Called as requireGlobalAdmin(req, res, next)
1712
// Parameters are shifted: forResource=req, req=res, res=next, next=undefined
18-
next = res; // res parameter is actually the next function
19-
res = req; // req parameter is actually the res object
13+
next = res; // res parameter is actually the next function
14+
res = req; // req parameter is actually the res object
2015
req = forResource; // forResource is the actual req object
2116
forResource = 'Global admin access';
2217
} else {
2318
forResource = forResource || 'Global admin access';
2419
}
2520

26-
console.error('[DEBUG] After shift - authMethod:', req.authMethod, 'userId:', req.user?.userId);
27-
2821
if (req.authMethod === 'api-secret') {
29-
console.error('[DEBUG] api-secret - calling next()');
3022
return next();
3123
}
3224

3325
if (req.authMethod === 'oauth') {
3426
const config = getConfig();
3527
const botOwners = getBotOwnerIds(config);
36-
console.error('[DEBUG] oauth - botOwners:', botOwners, 'userId:', req.user?.userId);
3728
if (botOwners.includes(req.user?.userId)) {
38-
console.error('[DEBUG] oauth owner - calling next()');
3929
return next();
4030
}
41-
console.error('[DEBUG] oauth non-owner - returning 403');
4231
return res.status(403).json({ error: `${forResource} requires bot owner permissions` });
4332
}
4433

45-
console.error('[DEBUG] unknown authMethod - returning 401');
4634
warn('Unknown authMethod in global admin check', {
4735
authMethod: req.authMethod,
4836
path: req.path,

src/api/routes/config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ export function validateConfigSchema(config) {
8282
* "403":
8383
* $ref: "#/components/responses/Forbidden"
8484
*/
85-
router.get("/", requireGlobalAdmin, (req, res) => {
86-
const fs = require("fs");
87-
try { fs.writeFileSync("/tmp/config-route.log", "Route handler called at " + Date.now()); } catch(e) {}
85+
router.get('/', requireGlobalAdmin, (req, res) => {
8886
const config = getConfig();
8987
const safeConfig = {};
9088

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ async function startup() {
520520
startGithubFeed(client);
521521
startScheduledBackups();
522522
startVoiceFlush();
523+
}
523524
// Load commands and login
524525
await loadCommands();
525526
await client.login(token);

0 commit comments

Comments
 (0)