forge
Explore
Log in

Don't you dare go Hollow

🔒 gate the class pages so a parent gets a 403, not a crash

Browse files at this commit

bd0720fadb83b0e253ea194a4da8fc683f0f9bb9Burak BoduroğluParent: 1f159c2
  • fix
    • 🔒 gate the class pages so a parent gets a 403, not a crash
Show full message
fix: 🔒 gate the class pages so a parent gets a 403, not a crash

- both pages wrapped their content in a bare RouteGuard with no role, so
  a parent reached them, the component fetched, and the backend's
  "requires teacher role or higher" bubbled past the guard to the root
  error boundary as "Something went wrong!"
- minRole teacher puts the refusal back where the neighbouring management
  pages keep it, and the reader now gets the branded 403 card

The authorization itself was never open — the server refused all along;
what leaked was a crash screen instead of an explanation.
src/pages/class-detail-page.tsxmodified+1 -1
@@ -40,7 +40,7 @@ import { useAuth } from "@/stores/auth-context";
40 import { useT } from "@/stores/preferences-context";40 import { useT } from "@/stores/preferences-context";
41 41
42 export default function ClassDetailPage() {42 export default function ClassDetailPage() {
43- return <RouteGuard><ClassDetailContent /></RouteGuard>;43+ return <RouteGuard minRole="teacher"><ClassDetailContent /></RouteGuard>;
44 }44 }
45 45
46 function ClassDetailContent() {46 function ClassDetailContent() {
src/pages/classes-page.tsxmodified+1 -1
@@ -33,7 +33,7 @@ import { useT } from "@/stores/preferences-context";
33 const MEMBER_COUNT_FETCH_CAP = 200;33 const MEMBER_COUNT_FETCH_CAP = 200;
34 34
35 export default function ClassesPage() {35 export default function ClassesPage() {
36- return <RouteGuard><ClassesContent /></RouteGuard>;36+ return <RouteGuard minRole="teacher"><ClassesContent /></RouteGuard>;
37 }37 }
38 38
39 function ClassesContent() {39 function ClassesContent() {