V 1.2.0 migration.tsx in proxy.tsx umbenannt
Loginpage eingebettet
This commit is contained in:
@@ -7,73 +7,77 @@ export default function LoginPage() {
|
|||||||
const [state, loginAction, isPending] = useActionState(login, undefined);
|
const [state, loginAction, isPending] = useActionState(login, undefined);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-gray-900 dark:to-gray-800 px-4">
|
<div className="min-h-screen bg-white py-4 px-4">
|
||||||
<div className="max-w-md w-full space-y-8 bg-white dark:bg-gray-800 p-8 rounded-2xl shadow-xl">
|
<main className="max-w-7xl mx-auto border-2 border-black rounded-lg p-6 bg-[#FFFFDD]">
|
||||||
<div className="text-center">
|
<h1 className="text-3xl font-bold mb-6">Ausgaben - Log</h1>
|
||||||
<h1 className="text-3xl font-bold text-gray-900 dark:text-white mb-2">
|
|
||||||
Anmeldung
|
|
||||||
</h1>
|
|
||||||
<p className="text-gray-600 dark:text-gray-400">
|
|
||||||
Bitte melden Sie sich an, um fortzufahren
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form action={loginAction} className="mt-8 space-y-6">
|
<div className="flex items-center justify-center py-8">
|
||||||
<div className="space-y-4">
|
<div className="max-w-md w-full space-y-8 bg-white p-8 rounded-2xl shadow-xl">
|
||||||
<div>
|
<div className="text-center">
|
||||||
<label
|
<h2 className="text-2xl font-bold mb-2">Anmeldung</h2>
|
||||||
htmlFor="username"
|
<p className="text-gray-600">
|
||||||
className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"
|
Bitte melden Sie sich an, um fortzufahren
|
||||||
>
|
</p>
|
||||||
Benutzername
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
id="username"
|
|
||||||
name="username"
|
|
||||||
type="text"
|
|
||||||
required
|
|
||||||
autoComplete="off"
|
|
||||||
className="appearance-none relative block w-full px-4 py-3 border border-gray-300 dark:border-gray-600 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white bg-white dark:bg-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors"
|
|
||||||
placeholder="Benutzername"
|
|
||||||
disabled={isPending}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<form action={loginAction} className="mt-8 space-y-6">
|
||||||
<label
|
<div className="space-y-4">
|
||||||
htmlFor="password"
|
<div>
|
||||||
className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"
|
<label
|
||||||
>
|
htmlFor="username"
|
||||||
Passwort
|
className="block text-sm font-medium text-gray-700 mb-1"
|
||||||
</label>
|
>
|
||||||
<input
|
Benutzername
|
||||||
id="password"
|
</label>
|
||||||
name="password"
|
<input
|
||||||
type="password"
|
id="username"
|
||||||
required
|
name="username"
|
||||||
autoComplete="new-password"
|
type="text"
|
||||||
className="appearance-none relative block w-full px-4 py-3 border border-gray-300 dark:border-gray-600 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white bg-white dark:bg-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors"
|
required
|
||||||
placeholder="Passwort"
|
autoComplete="off"
|
||||||
|
className="appearance-none relative block w-full px-4 py-3 border border-gray-300 placeholder-gray-500 text-gray-900 bg-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors"
|
||||||
|
placeholder="Benutzername"
|
||||||
|
disabled={isPending}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label
|
||||||
|
htmlFor="password"
|
||||||
|
className="block text-sm font-medium text-gray-700 mb-1"
|
||||||
|
>
|
||||||
|
Passwort
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="password"
|
||||||
|
name="password"
|
||||||
|
type="password"
|
||||||
|
required
|
||||||
|
autoComplete="new-password"
|
||||||
|
className="appearance-none relative block w-full px-4 py-3 border border-gray-300 placeholder-gray-500 text-gray-900 bg-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-colors"
|
||||||
|
placeholder="Passwort"
|
||||||
|
disabled={isPending}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{state?.error && (
|
||||||
|
<div className="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg text-sm">
|
||||||
|
{state.error}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
/>
|
className="w-full flex justify-center py-3 px-4 border border-transparent text-sm font-semibold rounded-lg text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 shadow-lg hover:shadow-xl"
|
||||||
</div>
|
>
|
||||||
|
{isPending ? 'Anmeldung läuft...' : 'Anmelden'}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{state?.error && (
|
</main>
|
||||||
<div className="bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-300 px-4 py-3 rounded-lg text-sm">
|
|
||||||
{state.error}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
disabled={isPending}
|
|
||||||
className="w-full flex justify-center py-3 px-4 border border-transparent text-sm font-semibold rounded-lg text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 shadow-lg hover:shadow-xl"
|
|
||||||
>
|
|
||||||
{isPending ? 'Anmeldung läuft...' : 'Anmelden'}
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ausgaben_next",
|
"name": "ausgaben_next",
|
||||||
"version": "1.1.0",
|
"version": "1.2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 3005",
|
"dev": "next dev -p 3005",
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import { jwtVerify } from 'jose';
|
|||||||
const SESSION_COOKIE_NAME = 'auth_session';
|
const SESSION_COOKIE_NAME = 'auth_session';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Middleware to protect routes with authentication
|
* Proxy to protect routes with authentication
|
||||||
* Reusable for other projects - just copy this file
|
* Reusable for other projects - just copy this file
|
||||||
*/
|
*/
|
||||||
export async function middleware(request: NextRequest) {
|
export async function proxy(request: NextRequest) {
|
||||||
const { pathname } = request.nextUrl;
|
const { pathname } = request.nextUrl;
|
||||||
|
|
||||||
// Check if authentication is enabled
|
// Check if authentication is enabled
|
||||||
@@ -58,6 +58,8 @@ export async function middleware(request: NextRequest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default proxy;
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
matcher: [
|
matcher: [
|
||||||
/*
|
/*
|
||||||
Reference in New Issue
Block a user