diff --git a/backend/api/__pycache__/functions.cpython-313.pyc b/backend/api/__pycache__/functions.cpython-313.pyc index f2d42fc..06ce5f8 100644 Binary files a/backend/api/__pycache__/functions.cpython-313.pyc and b/backend/api/__pycache__/functions.cpython-313.pyc differ diff --git a/backend/api/__pycache__/views.cpython-313.pyc b/backend/api/__pycache__/views.cpython-313.pyc index cd31048..b4d9b59 100644 Binary files a/backend/api/__pycache__/views.cpython-313.pyc and b/backend/api/__pycache__/views.cpython-313.pyc differ diff --git a/backend/api/functions.py b/backend/api/functions.py index 8561600..3c579a8 100644 --- a/backend/api/functions.py +++ b/backend/api/functions.py @@ -66,7 +66,7 @@ def generate_waf_rule(cve_id: str, description: str, severity: str, mode: str, w description (str): CVE description severity (str): CVSS/impact level mode (str): "JSON" or "cURL" - waf (str): Target WAF provider ("AWS", "Azure", "GCP", "Cloudflare") + waf (str): Target WAF provider ("AWS", "Azure", "GCP", "Cloudflare", "Akamai", "Imperva") Returns: dict: { "waf_rule": ... } """ @@ -154,5 +154,5 @@ def generate_testing_code(cve_id: str, description: str, severity: str): sample_cve_id = "CVE-2025-26000" sample_description = "A vulnerability in the Python library 'requests' allows attackers to execute arbitrary code via a crafted HTTP request." sample_severity = "High" - result = generate_exploit(sample_cve_id, sample_description, sample_severity) + result = generate_testing_code(sample_cve_id, sample_description, sample_severity) print(result) diff --git a/backend/api/views.py b/backend/api/views.py index 4e856ac..c1c2f59 100644 --- a/backend/api/views.py +++ b/backend/api/views.py @@ -114,8 +114,17 @@ def post(self, request): } }, status=status.HTTP_201_CREATED) else: + # Format validation errors for better frontend handling + formatted_errors = {} + for field, errors in serializer.errors.items(): + if isinstance(errors, list): + formatted_errors[field] = [str(error) for error in errors] + else: + formatted_errors[field] = [str(errors)] + return Response({ - "message": f"User Not Created {serializer.errors}" + "message": "User registration failed", + "errors": formatted_errors }, status=status.HTTP_400_BAD_REQUEST) def _store_cve_data_for_user(self, user): diff --git a/backend/db.sqlite3 b/backend/db.sqlite3 index a3c851f..e473907 100644 Binary files a/backend/db.sqlite3 and b/backend/db.sqlite3 differ diff --git a/frontend/app/login/page.tsx b/frontend/app/login/page.tsx index e4690c1..02db82e 100644 --- a/frontend/app/login/page.tsx +++ b/frontend/app/login/page.tsx @@ -1,6 +1,6 @@ "use client" -import { useState } from "react" +import { useState, useEffect } from "react" import { useRouter } from "next/navigation" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" @@ -14,12 +14,25 @@ export default function LoginPage() { const [password, setPassword] = useState("") const [error, setError] = useState("") const [loading, setLoading] = useState(false) - const { login } = useAuth() + const { login, isAuthenticated, loading: authLoading } = useAuth() const router = useRouter() + // Redirect if already authenticated + useEffect(() => { + if (!authLoading && isAuthenticated) { + router.push("/dashboard") + } + }, [isAuthenticated, authLoading, router]) + const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError("") + + // Prevent multiple login attempts + if (loading) { + return + } + setLoading(true) try { @@ -27,18 +40,40 @@ export default function LoginPage() { if (result.success) { // Add a small delay to ensure authentication state is properly set setTimeout(() => { - router.push("/dashboard") + try { + router.push("/dashboard") + } catch (navigationError) { + console.error("Navigation error:", navigationError) + // If navigation fails, the useEffect will handle the redirect + } }, 100) } else { - setError(result.error || "Login failed") + setError(result.error || "Login failed. Please check your credentials and try again.") } } catch (err) { - setError("An unexpected error occurred") + console.error("Login error:", err) + setError("An unexpected error occurred. Please try again later.") } finally { setLoading(false) } } + // Show loading state while checking authentication + if (authLoading) { + return ( +
+ + +
+
+

Checking authentication...

+
+
+
+
+ ) + } + return (
@@ -73,7 +108,9 @@ export default function LoginPage() { />
{error && ( -
{error}
+
+
{error}
+
)}