diff --git a/backend/hermes/app/api/auth.py b/backend/hermes/app/api/auth.py index d26eea6..b209265 100644 --- a/backend/hermes/app/api/auth.py +++ b/backend/hermes/app/api/auth.py @@ -32,7 +32,7 @@ def login( key="access_token", value=token, httponly=True, - secure=True, + secure=False, samesite="lax", max_age=3600, ) diff --git a/frontend/athena/app/dashboard/page.tsx b/frontend/athena/app/dashboard/page.tsx new file mode 100644 index 0000000..fb4dde8 --- /dev/null +++ b/frontend/athena/app/dashboard/page.tsx @@ -0,0 +1,15 @@ +export default function DashboardPage() { + return ( +
+
+

+ Olympus Dashboard +

+ +

+ Willkommen bei Funktechnik Schubert. +

+
+
+ ); + } \ No newline at end of file diff --git a/frontend/athena/app/login/page.tsx b/frontend/athena/app/login/page.tsx new file mode 100644 index 0000000..9bc693c --- /dev/null +++ b/frontend/athena/app/login/page.tsx @@ -0,0 +1,79 @@ +"use client"; + +import { useState } from "react"; +import { useRouter } from "next/navigation"; + +export default function LoginPage() { + const router = useRouter(); + + const [username, setUsername] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(""); + + async function handleLogin(e: React.FormEvent) { + e.preventDefault(); + setError(""); + + const response = await fetch( + `${process.env.NEXT_PUBLIC_API_URL}/auth/login`, + { + method: "POST", + credentials: "include", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + username, + password, + }), + } + ); + + if (response.ok) { + router.push("/dashboard"); + return; + } + + setError("Benutzername oder Passwort ist falsch."); + } + + return ( +
+
+

+ Olympus CRM +

+ + setUsername(e.target.value)} + /> + + setPassword(e.target.value)} + /> + + {error && ( +

+ {error} +

+ )} + + +
+
+ ); +} \ No newline at end of file diff --git a/frontend/athena/app/page.tsx b/frontend/athena/app/page.tsx index 330cb12..3edf46d 100644 --- a/frontend/athena/app/page.tsx +++ b/frontend/athena/app/page.tsx @@ -1,20 +1,5 @@ -import StatCard from "@/components/StatCard"; -import UserCounter from "@/components/UserCounter"; +import { redirect } from "next/navigation"; -export default function Home() { - return ( - <> -
- - } /> - - - - - - - -
- - ); +export default function HomePage() { + redirect("/login"); } \ No newline at end of file diff --git a/frontend/athena/middleware.ts b/frontend/athena/middleware.ts new file mode 100644 index 0000000..cd079d2 --- /dev/null +++ b/frontend/athena/middleware.ts @@ -0,0 +1,18 @@ +import { NextRequest, NextResponse } from "next/server"; + +export function middleware(request: NextRequest) { + const token = request.cookies.get("access_token"); + + if (!token) { + return NextResponse.redirect(new URL("/login", request.url)); + } + + return NextResponse.next(); +} + +export const config = { + matcher: [ + "/dashboard/:path*", + "/users/:path*", + ], +}; \ No newline at end of file