auto-claude: subtask-1-1 - Import and integrate rate limiting into LoginForm.
- Added rateLimiter import from utils/rateLimiting - Integrated rate limiting check before auth attempt - Follows ContactForm.tsx pattern exactly - Checks isRateLimited() and throws error with time to reset
This commit is contained in:
@@ -5,6 +5,7 @@ import { useRouter } from 'next/navigation';
|
|||||||
import { Lock, Loader2 } from 'lucide-react';
|
import { Lock, Loader2 } from 'lucide-react';
|
||||||
import { useTranslations, useLocale } from 'next-intl';
|
import { useTranslations, useLocale } from 'next-intl';
|
||||||
import { createClient } from '@/lib/supabase/client';
|
import { createClient } from '@/lib/supabase/client';
|
||||||
|
import { rateLimiter } from '../../utils/rateLimiting';
|
||||||
|
|
||||||
export default function LoginForm() {
|
export default function LoginForm() {
|
||||||
const t = useTranslations('login');
|
const t = useTranslations('login');
|
||||||
@@ -21,6 +22,13 @@ export default function LoginForm() {
|
|||||||
setError(null);
|
setError(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Check rate limiting
|
||||||
|
const clientIp = '127.0.0.1'; // In production, get this from the request
|
||||||
|
if (rateLimiter.isRateLimited(clientIp)) {
|
||||||
|
const timeToReset = Math.ceil(rateLimiter.getTimeToReset(clientIp) / 1000 / 60);
|
||||||
|
throw new Error(`Too many attempts. Please try again in ${timeToReset} minutes.`);
|
||||||
|
}
|
||||||
|
|
||||||
const supabase = createClient();
|
const supabase = createClient();
|
||||||
const { error } = await supabase.auth.signInWithPassword({
|
const { error } = await supabase.auth.signInWithPassword({
|
||||||
email,
|
email,
|
||||||
|
|||||||
Reference in New Issue
Block a user