import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';

export const GET: RequestHandler = async ({ locals }) => {
	const { session, user } = await locals.safeGetSession();

	if (!session || !user) {
		return json({ verified: false, error: 'Not authenticated' }, { status: 401 });
	}

	// Check if email is verified
	// In Supabase, this is stored in user metadata
	const emailVerified = user.email_confirmed_at !== null;

	return json({ verified: emailVerified });
};
