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:
parent
b7589b702a
commit
cd21697af3
1 changed files with 17 additions and 8 deletions
|
|
@ -28,7 +28,16 @@ async function getUserWithApps(userId) {
|
||||||
)
|
)
|
||||||
if (!user) return null
|
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
|
`SELECT a.slug, a.name, a.description, a.base_path, a.icon, a.theme_color
|
||||||
FROM apps a
|
FROM apps a
|
||||||
JOIN user_app_perms p ON p.app_id = a.id
|
JOIN user_app_perms p ON p.app_id = a.id
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue