Skip to content

Instantly share code, notes, and snippets.

@Jonahbkerr
Created February 12, 2026 16:51
Show Gist options
  • Select an option

  • Save Jonahbkerr/c447481da77d7fe56cd8a2ac30112d30 to your computer and use it in GitHub Desktop.

Select an option

Save Jonahbkerr/c447481da77d7fe56cd8a2ac30112d30 to your computer and use it in GitHub Desktop.
Fix platform dashboard login: increase DB timeout + eliminate redundant admin query
diff --git a/backend/src/db.ts b/backend/src/db.ts
index bc067d8..9fa21e9 100644
--- a/backend/src/db.ts
+++ b/backend/src/db.ts
@@ -6,7 +6,7 @@ const pool = new Pool({
connectionString: process.env.DATABASE_URL,
max: 20,
idleTimeoutMillis: 30000,
- connectionTimeoutMillis: 2000,
+ connectionTimeoutMillis: 10000,
});
pool.on('error', (err) => {
diff --git a/backend/src/routes/auth.ts b/backend/src/routes/auth.ts
index 2aef333..51bdb83 100644
--- a/backend/src/routes/auth.ts
+++ b/backend/src/routes/auth.ts
@@ -369,17 +369,8 @@ router.post(
router.get('/user', authenticate, async (req, res) => {
const authReq = req as unknown as AuthenticatedRequest;
- // Check if user is a platform admin
- let is_platform_admin = false;
- try {
- const adminCheck = await query(
- 'SELECT is_system_admin FROM users WHERE id = $1',
- [authReq.user!.id]
- );
- is_platform_admin = adminCheck.rows[0]?.is_system_admin === true;
- } catch {
- // Column may not exist yet
- }
+ // Check if user is a platform admin (already loaded by authenticate middleware)
+ const is_platform_admin = (authReq.user as any)?.is_system_admin === true;
// Load org context if user has an organization
let organization = null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment