mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 15:11:12 -05:00
Fix Supabase linter warnings and backend validation
This commit is contained in:
35
src/lib/emailValidation.ts
Normal file
35
src/lib/emailValidation.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
|
||||
interface EmailValidationResult {
|
||||
valid: boolean;
|
||||
reason?: string;
|
||||
suggestions?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an email address against disposable email domains
|
||||
* Uses the validate-email edge function to check the backend blocklist
|
||||
*/
|
||||
export async function validateEmailNotDisposable(email: string): Promise<EmailValidationResult> {
|
||||
try {
|
||||
const { data, error } = await supabase.functions.invoke('validate-email', {
|
||||
body: { email }
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error('Email validation error:', error);
|
||||
return {
|
||||
valid: false,
|
||||
reason: 'Unable to validate email address. Please try again.'
|
||||
};
|
||||
}
|
||||
|
||||
return data as EmailValidationResult;
|
||||
} catch (error) {
|
||||
console.error('Email validation exception:', error);
|
||||
return {
|
||||
valid: false,
|
||||
reason: 'Unable to validate email address. Please try again.'
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user