Commit 01f8164
fix(courses): use admin client for teacher course pages to fix RLS mismatch
The JWT's tenant_id claim (from app_metadata) doesn't match the actual
subdomain tenant ID. RLS get_tenant_id() reads JWT claims, so queries
return empty results even for valid courses. The middleware sets the
correct tenant ID via x-tenant-id header (getCurrentTenantId()), but
RLS can't use that.
Fix: use createAdminClient() for course detail page queries with manual
tenant_id filtering from the header. Auth is validated via
getCurrentUserId(). Ownership check remains on author_id.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent d8850c2 commit 01f8164
1 file changed
Lines changed: 4 additions & 3 deletions
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
0 commit comments