Admins implicitly see all active apps (fixes empty portal for admin)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-01 14:59:51 +00:00
parent b7589b702a
commit cd21697af3

View file

@ -28,7 +28,16 @@ async function getUserWithApps(userId) {
)
if (!user) return null
const { rows: apps } = await pool.query(
// Admins implicitly have access to every active app; everyone else sees
// only the apps explicitly granted to them via user_app_perms.
const { rows: apps } = user.is_admin
? await pool.query(
`SELECT a.slug, a.name, a.description, a.base_path, a.icon, a.theme_color
FROM apps a
WHERE a.active = true
ORDER BY a.name`
)
: await pool.query(
`SELECT a.slug, a.name, a.description, a.base_path, a.icon, a.theme_color
FROM apps a
JOIN user_app_perms p ON p.app_id = a.id