Admin qr sacnner - #199
Merged
Merged
Conversation
…nd-code-generation
… attendance admin function
rebeccafitzpatr
approved these changes
Aug 19, 2026
There was a problem hiding this comment.
Pull request overview
Adds an admin-facing QR check-in flow: members can fetch/display a personal QR payload from their profile, and admins can scan that QR to mark a member as attended for a selected event via new Next.js API routes backed by Supabase.
Changes:
- Introduces server-only Supabase service-role client and new API endpoints for issuing member QR payloads and verifying admin check-ins.
- Adds UI for member QR display (profile hover card) and admin camera-based scanning + event selection.
- Updates Reown AppKit initialization and adds dev configuration for ngrok origin allowlisting.
Reviewed changes
Copilot reviewed 12 out of 15 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/services/supabase-admin.ts | Adds a server-only Supabase client using the service role key for admin-only DB operations. |
| src/lib/wallet-auth.ts | Adds wallet-signed header verification helper used to authorize QR issuance. |
| src/components/web3-provider.tsx | Adjusts AppKit network typing and adds metadata for AppKit initialization. |
| src/app/profile/page.tsx | Adds member QR hover UI and updates attended-event detail fetching/display logic. |
| src/app/api/user/qr/route.ts | Adds endpoint to issue/return per-member QR secret (stored on profile). |
| src/app/api/admin/events/route.ts | Tweaks admin auth verification logic for events listing (and adds an unused import). |
| src/app/api/admin/checkin/verify/route.ts | Adds endpoint to validate scanned QR secret and append event attendance. |
| src/app/admin/page.tsx | Refactors admin overview page to do its own auth + data fetching. |
| src/app/admin/attendance/page.tsx | Implements admin attendance scanner UI using qr-scanner + admin auth headers. |
| package.json | Adds dependencies for QR generation/scanning and server-only guard. |
| next.config.ts | Adds allowedDevOrigins to enable ngrok/localtunnel testing in dev. |
| bun.lock | Locks new dependencies. |
| .env.example | Documents env vars required for Supabase/admin/AppKit. |
Suppressed comments (2)
src/app/api/admin/checkin/verify/route.ts:112
- The success log after a new check-in incorrectly records
alreadyCheckedIn: true, which contradicts the actual response (alreadyCheckedIn: false) and makes logs misleading for ops/debugging.
console.log("[admin-checkin] scan success", {
eventId,
memberName,
alreadyCheckedIn: true,
scannedAt: new Date().toISOString(),
});
src/app/api/admin/events/route.ts:19
verifyAdminAuthapplies the timestamp skew check twice and usesparseInt(timestamp)without validating it.NaN(or future timestamps) can bypass the check; having two checks is redundant and easy to drift out of sync.
if (Date.now() - parseInt(timestamp) > 5 * 60 * 1000) return false;
// Prevent replay attacks (valid for 5 mins)
const now = Date.now();
if (now - parseInt(timestamp) > 5 * 60 * 1000) return false;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+16
to
+17
| if (!address || !signature || !timestamp) return null; | ||
| if (Date.now() - parseInt(timestamp) > MAX_CLOCK_SKEW_MS) return null; |
Comment on lines
+13
to
+15
| // Longer window than other admin routes (5 min) since this gets reused | ||
| // across a whole door-scanning session instead of a single one-off action. | ||
| if (Date.now() - parseInt(timestamp) > 4 * 60 * 60 * 1000) return false; |
Comment on lines
2
to
+6
| import { getSupabase } from "@/services/supabase"; | ||
| import { RegistrationService } from "@/services/registrations/registrations-service"; | ||
| import { verifyMessage } from "viem"; | ||
| import { isAllowedAdminAddress } from "@/lib/admin-auth"; | ||
| import { getSupabaseAdmin } from "@/services/supabase-admin"; |
Comment on lines
+38
to
+43
| metadata: { | ||
| name: "web3", | ||
| description: "web3", | ||
| url: "http://localhost:3000", | ||
| icons: [], | ||
| }, |
Comment on lines
+88
to
+100
| // Re-render the QR whenever the payload or theme changes, so it stays | ||
| // black-on-white in light mode and white-on-transparent in dark mode. | ||
| useEffect(() => { | ||
| if (!qrPayload) return; | ||
|
|
||
| QrCode.toDataURL(qrPayload, { | ||
| errorCorrectionLevel: "H", | ||
| margin: 2, | ||
| color: { dark: "#000000", light: "#FFFFFF" }, | ||
| }) | ||
| .then(setQrImage) | ||
| .catch((error) => setQrError(getErrorMessage(error))); | ||
| }, [qrPayload]); |
Comment on lines
202
to
+206
| const supabase = getSupabase(); | ||
| const { data, error } = await supabase | ||
| .from("events") | ||
| .select("title,event_url") | ||
| .in("title", attended); | ||
| .select("id,title,event_url") | ||
| .in("id", attended); |
Comment on lines
+3
to
7
| import { useEffect, useRef, useState } from "react"; | ||
| import { useWallet } from "@/hooks/use-wallet"; | ||
| import { Button } from "@/components/ui/button"; | ||
| import { WalletButton } from "@/components/wallet-button"; | ||
| import Link from "next/link"; |
| # Required variables for Next.js to run | ||
|
|
||
|
|
||
| NEXT_PUBLIC_SUPABASE_URL=https://xxx.supabase.co/rest/v1/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Admin QR Check-In Scanner
Admins can now scan a member's personal check-in QR (from their profile page) to mark them attended for a specific event.
What's new:
we are using ngrok to test this
Steps to test on mobile with ngrok
Note:
Make sure you have reown account created and add the domain to it
make sure have the next.config up
this i for whitelisitng ngrok domains so Next.js's dev server doesn't block requests coming from your phone through the tunnel.
Known limitation: ngrok's free tier gives a random URL each run, which needs re-adding to the Reown Cloud project's allowed origins every time — not an issue once this is deployed to a real domain.