Created
February 12, 2026 16:58
-
-
Save Jonahbkerr/3cf678296dbc3250063cac838c1841ad to your computer and use it in GitHub Desktop.
Fix: use already-loaded user data for admin check instead of redundant DB query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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