Skip to content

Admin qr sacnner - #199

Merged
rebeccafitzpatr merged 14 commits into
mainfrom
feature/191-admin-qr-sacnner
Aug 19, 2026
Merged

Admin qr sacnner#199
rebeccafitzpatr merged 14 commits into
mainfrom
feature/191-admin-qr-sacnner

Conversation

@Wuuuuu5

@Wuuuuu5 Wuuuuu5 commented Aug 12, 2026

Copy link
Copy Markdown

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:

  • Admin dashboard has a "Check Event Attendance" card — pick an event from the dropdown, tap "Scan Code," point the camera at a member's QR.
  • New API routes: /api/admin/checkin/verify (validates scan + records attendance) and /api/admin/events (populates the event dropdown from Supabase).
  • Uses qr-scanner for camera-based decoding.

we are using ngrok to test this

Steps to test on mobile with ngrok

  1. Install (one-time): brew install ngrok or what package manager ur using
  2. Sign up / get token (one-time): https://dashboard.ngrok.com/get-started/your-authtoken
  3. Save token (one-time): ngrok config add-authtoken
  4. Start dev server (terminal 1): bun dev
  5. Start tunnel (terminal 2): ngrok http 3000
  6. Open the printed URL (looks like https://xxxx.ngrok-free.app) on your phone's browser

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • verifyAdminAuth applies the timestamp skew check twice and uses parseInt(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 thread src/lib/wallet-auth.ts
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 thread src/app/profile/page.tsx
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 thread src/app/profile/page.tsx
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 thread src/app/admin/page.tsx
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";
Comment thread .env.example
# Required variables for Next.js to run


NEXT_PUBLIC_SUPABASE_URL=https://xxx.supabase.co/rest/v1/
@rebeccafitzpatr
rebeccafitzpatr merged commit f27ad02 into main Aug 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants