Voucher System
Overview
The Voucher System provides passcode-based access control for the photobooth. When enabled, users must scan a QR code or enter a passcode before they can access the frame selection and proceed with their photo session.
Configuration Settings
interface VoucherSettings {
active: boolean; // Enable/disable voucher requirement
passcode: string; // Required passcode (configurable by vendor)
}
User Flow
- Frame Selection: User arrives at
/frame-selection - Voucher Check: System checks if
settings.voucher.active === true - Prompt: If active, user sees voucher scan prompt (QR scanner or passcode input)
- Verification: User scans QR or enters passcode
- Validation:
VoucherProvider.verify()checks against stored passcode - Access Granted: On success,
sessionStorage['photobooth-voucher-verified'] = true - Proceed: User can now select frames and continue normally
Provider: VoucherProvider
Location: apps/web/providers/voucher-provider.tsx
interface VoucherContextType {
isVerified: boolean; // Current verification state
verify: (passcode: string) => boolean; // Verify passcode, returns success
clearVerification: () => void; // Clear verification (for new session)
}
State Management
- In-memory state:
isVerifiedboolean - Persistence:
sessionStorage['photobooth-voucher-verified'](boolean) - Settings source:
SettingsProviderviauseSettings()
Verification Logic
const verify = (passcode: string): boolean => {
if (!voucherActive || !storedPasscode) return false;
const matches = passcode.trim() === storedPasscode.trim();
if (matches) {
writeVoucherVerification(true); // Persist to sessionStorage
setIsVerified(true);
}
return matches;
};
Integration Points
| Component | Usage |
|---|---|
routes/frame-selection.tsx | Checks useVoucher().isVerified before showing frames |
hooks/use-voucher-settings.ts | Loads voucher configuration |
lib/workflow-session.ts | readVoucherVerification() / writeVoucherVerification() |
Configuration Location
Vendor configures in /customization → Voucher Settings Tab:
- Toggle: Enable/disable voucher system
- Passcode: Set required passcode (alphanumeric)
Security Notes
- Passcode is stored in plain text in settings (acceptable for event-based access)
- Verification state is per-session (cleared when browser tab closes)
- Manual "clear" available via
clearVerification()for new sessions