From 59c1bb0366b1c5a8caca40f3b731bcde0ae7ca6f Mon Sep 17 00:00:00 2001 From: Maulana Sodiqin Date: Wed, 10 Dec 2025 21:30:28 +0700 Subject: [PATCH] feat: make certificate page publicly accessible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add /certificate/* to public routes in root layout - Display team leader name instead of current user - Remove authentication requirement for viewing certificates - Certificates now work without login 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/hackathon/src/app/certificate/[certId]/page.tsx | 8 +++----- apps/hackathon/src/app/layout.tsx | 6 ++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/hackathon/src/app/certificate/[certId]/page.tsx b/apps/hackathon/src/app/certificate/[certId]/page.tsx index de0e5ac..aaa23b5 100644 --- a/apps/hackathon/src/app/certificate/[certId]/page.tsx +++ b/apps/hackathon/src/app/certificate/[certId]/page.tsx @@ -5,7 +5,6 @@ import { decodeCertificateId } from '../../../utils/certificate'; import { useTeamById, useTeamSubmission, - useAuthStore, } from '@imphnen-frontend-service/service'; import QRCode from 'qrcode'; import html2canvas from 'html2canvas'; @@ -18,7 +17,6 @@ interface DecodedCert { const CertificatePage: FC = (): ReactElement => { const { certId } = useParams<{ certId: string }>(); const navigate = useNavigate(); - const { session } = useAuthStore(); const [decodedInfo, setDecodedInfo] = useState(null); const [error, setError] = useState(null); const teamNameRef = useRef(null); @@ -100,7 +98,7 @@ const CertificatePage: FC = (): ReactElement => { }, 0); return () => clearTimeout(timer); - }, [team?.name, session?.user?.fullname]); + }, [team?.name, team?.leader?.fullname]); // Generate certificate canvas screenshot useEffect(() => { @@ -132,7 +130,7 @@ const CertificatePage: FC = (): ReactElement => { }; generateCertificate(); - }, [team, submission, qrCodeUrl, session?.user?.fullname]); + }, [team, submission, qrCodeUrl]); // Download certificate const handleDownloadCertificate = () => { @@ -337,7 +335,7 @@ const CertificatePage: FC = (): ReactElement => { margin: 0, }} > - {session?.user?.fullname || 'N/A'} + {team?.leader?.fullname || 'N/A'} diff --git a/apps/hackathon/src/app/layout.tsx b/apps/hackathon/src/app/layout.tsx index a038a12..3c59f0c 100644 --- a/apps/hackathon/src/app/layout.tsx +++ b/apps/hackathon/src/app/layout.tsx @@ -52,6 +52,12 @@ export default function RootLayout() { return; } + // Certificate page - allow public access + if (pathname.startsWith('/certificate/')) { + setIsChecking(false); + return; + } + // Require authentication for all other routes if (!session) { navigate('/auth/login', { replace: true });