diff --git a/src/components/CommentSection.tsx b/src/components/CommentSection.tsx
index fb3dc61..ac38ced 100644
--- a/src/components/CommentSection.tsx
+++ b/src/components/CommentSection.tsx
@@ -5,11 +5,13 @@ import { createPortal } from 'react-dom';
import { Send, Trash2, MessageCircle, X } from 'lucide-react';
import { useAuth } from '@/contexts/AuthContext';
import { useEventComments } from '@/hooks/useEventComments';
+import { supabase } from '@/lib/supabase';
import { timeAgo } from '@/lib/time-parse';
import { getDisplayName } from '@/lib/user-display';
import UserAvatar from './UserAvatar';
import ProfileCardModal from './ProfileCardModal';
import { trackCommentExpand, trackCommentAdd, trackCommentDelete, trackCommentVisibilityToggle } from '@/lib/analytics';
+import { useXVerification } from '@/hooks/useXVerification';
interface CommentSectionProps {
eventId: string;
@@ -19,6 +21,7 @@ interface CommentSectionProps {
export function CommentSection({ eventId, commentCount = 0, eventName }: CommentSectionProps) {
const { user } = useAuth();
+ const { isXVerified, linkX } = useXVerification();
const [expanded, setExpanded] = useState(false);
const [isMobile, setIsMobile] = useState(false);
const { comments, loading, addComment, deleteComment } = useEventComments(
@@ -26,6 +29,10 @@ export function CommentSection({ eventId, commentCount = 0, eventName }: Comment
);
const [text, setText] = useState('');
const [visibility, setVisibility] = useState<'public' | 'friends'>('public');
+ const [showEmailPrompt, setShowEmailPrompt] = useState(false);
+ const [email, setEmail] = useState('');
+ const [emailLoading, setEmailLoading] = useState(false);
+ const [emailError, setEmailError] = useState(null);
const [selectedProfile, setSelectedProfile] = useState<{
userId: string;
displayName?: string | null;
@@ -163,8 +170,37 @@ export function CommentSection({ eventId, commentCount = 0, eventName }: Comment
>
);
+ // Handle email sign-up then X OAuth link
+ const handleEmailThenLinkX = async () => {
+ if (!email.trim()) return;
+ setEmailLoading(true);
+ setEmailError(null);
+
+ // Sign up with a random password — auto-confirms since enable_confirmations = false
+ // Next login they'll use OTP
+ const { error } = await supabase.auth.signUp({
+ email: email.trim(),
+ password: crypto.randomUUID(),
+ });
+
+ if (error) {
+ // If account exists, they need to sign in properly
+ if (error.message?.includes('already registered') || error.status === 422) {
+ setEmailError('Account exists — sign in from the menu first');
+ } else {
+ setEmailError(error.message);
+ }
+ setEmailLoading(false);
+ return;
+ }
+
+ // Account created + session active, now start X OAuth
+ setEmailLoading(false);
+ linkX();
+ };
+
// Shared input content
- const inputContent = user && (
+ const inputContent = user && isXVerified ? (
+ ) : user && !isXVerified ? (
+ // Logged in but X not verified — go straight to X OAuth
+
+ ) : showEmailPrompt ? (
+ // Not logged in — email prompt before X OAuth
+