Verification Gate System
Haven ensures a safe environment for members by enforcing Verification Gates before they can interact with the community.
🏁 Purpose
To prevent bots and bad actors from entering the match pool or joining sensitive Sangha channels.
🧱 Implementation Architecture
1. The Database Root (profiles)
We use a Single Source of Truth for a member's identity:
is_verified: Boolean flag (true/false).verification_level:none,basic,full.age_verified: Boolean from our TensorFlow JS check.email_confirmed_at: From Supabase Auth.
2. The Verification Middleware
Every request is checked by middleware.ts before reaching any protected route (/sangha, /chat).
- Wait/Success Case: If a user is verified, a header
x-user-verified: trueis injected, and they are allowed to pass. - Fail Case: If verification is missing, they are redirected to
/verify.
3. The React Hook (useVerificationGate)
A centralized hook that tracks the user's status in real-time.
- Auto-Redirect: If the user's status changes (e.g., they complete the age check), the hook immediately refreshes the UI and redirects them to their original destination.
🚀 Usage for Developers
Protect a Page Segment:
import { VerificationGate } from '@/components/VerificationGate'
export default function MyProtectedPage() {
return (
<VerificationGate>
{/* Only visible to verified members */}
<MyRestrictedComponent />
</VerificationGate>
)
}
Protect an Action:
const { isVerified, requireVerification } = useVerificationGate()
const handleAction = () => {
if (!requireVerification()) return // Auto-blocks and guides the user to /verify
// Proceed with action
}
🚦 Future-Proofing
The system is designed to be Add-Only. Adding phone verification or ID-matching only requires updating the check_user_verification SQL function. No frontend code changes are needed to the existing gates.
Created by the Antigravity Security Council.