@@ -164,13 +164,21 @@ export default function ReportCard() {
164164 const reportData = json . data ?? null ;
165165
166166 // Check access control: only allow the creator of the submission to view the report
167- if ( reportData && currentUser ) {
167+ // Exception: reports generated by guests (EXTERNAL.guest_user_id) are publicly viewable
168+ if ( reportData ) {
168169 const submissionUserId = reportData . submission ?. user_created ?. id ;
169- if ( submissionUserId && submissionUserId !== currentUser . id ) {
170- throw new Error ( "Access denied. You can only view reports for your own submissions." ) ;
170+ const isGuestReport = submissionUserId === EXTERNAL . guest_user_id ;
171+
172+ if ( ! isGuestReport ) {
173+ // For non-guest reports, enforce strict access control
174+ if ( ! currentUser ) {
175+ throw new Error ( "Please log in to view this report." ) ;
176+ }
177+ if ( submissionUserId && submissionUserId !== currentUser . id ) {
178+ throw new Error ( "Access denied. You can only view reports for your own submissions." ) ;
179+ }
171180 }
172- } else if ( reportData && ! currentUser ) {
173- throw new Error ( "Please log in to view this report." ) ;
181+ // Guest reports are accessible to everyone, no additional checks needed
174182 }
175183
176184 setReport ( reportData ) ;
@@ -292,17 +300,10 @@ export default function ReportCard() {
292300 return (
293301 < >
294302 < Card className = "w-full" >
295- < CardHeader className = "relative" >
303+ < CardHeader >
296304 < CardTitle className = "text-center" >
297305 Role Fit Index Report
298306 </ CardTitle >
299- < Button
300- onClick = { handlePrint }
301- className = "absolute top-1/2 right-6 -translate-y-1/2 flex items-center gap-2"
302- >
303- < Download className = "h-4 w-4" />
304- Download PDF
305- </ Button >
306307 </ CardHeader >
307308 < CardContent className = "space-y-8" >
308309 { /* Header */ }
@@ -509,6 +510,17 @@ export default function ReportCard() {
509510 </ LoginMask >
510511 </ div >
511512 </ div >
513+
514+ { /* Download Button */ }
515+ < div className = "flex justify-center pt-4" >
516+ < Button
517+ onClick = { handlePrint }
518+ className = "flex items-center gap-2"
519+ >
520+ < Download className = "h-4 w-4" />
521+ Download PDF
522+ </ Button >
523+ </ div >
512524 </ CardContent >
513525 </ Card >
514526
0 commit comments