Files
neta/app/login/page.tsx
T
Poyraz Avsever 950522d467 feat: Implement first admin setup guard to lock registration after initial account creation
- Updated the registration flow to check if the first admin account has been created, preventing further public registrations.
- Introduced `is_first_admin_setup_available` function to determine registration availability.
- Modified the `/register` and `/login` pages to redirect based on the setup state.
- Enhanced the user creation process to handle internal admin accounts correctly.
- Added migration script to enforce the new registration rules in the database.
- Refactored chat API to improve message handling and context building.
- Updated dashboard and settings components for better state management.
- Improved error handling and user feedback across various components.
2026-06-08 16:22:26 +03:00

94 lines
3.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { login } from "@/app/login/actions";
import { AuthPageShell } from "@/components/auth/auth-page-shell";
import { ErrorToaster } from "@/components/error-toaster";
import { getFirstAdminSetupState } from "@/lib/auth/first-admin-setup";
import { LockKeyhole, LogIn, Mail } from "lucide-react";
import Link from "next/link";
import { Button, Input, Label } from "poyraz-ui/atoms";
export default async function LoginPage({
searchParams,
}: {
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
}) {
const [resolvedParams, setupState] = await Promise.all([
searchParams,
getFirstAdminSetupState(),
]);
const error = resolvedParams?.error;
const message = resolvedParams?.message;
return (
<>
{error && message && <ErrorToaster message={String(message)} />}
<AuthPageShell
title="Giriş yap"
description="Cognis çalışma alanına erişmek için hesabına giriş yap."
form={
<form className="space-y-6">
<div className="space-y-4">
<div className="space-y-2">
<Label htmlFor="email" className="flex items-center gap-2">
<Mail className="h-4 w-4 text-muted-foreground" />
E-posta
</Label>
<Input
id="email"
name="email"
type="email"
placeholder="ornek@mail.com"
required
className="h-11"
/>
</div>
<div className="space-y-2">
<div className="flex items-center justify-between gap-3">
<Label htmlFor="password" className="flex items-center gap-2">
<LockKeyhole className="h-4 w-4 text-muted-foreground" />
Şifre
</Label>
<Link
href="/forgot-password"
className="text-sm font-medium text-primary transition-colors hover:text-primary-hover"
>
Şifremi unuttum
</Link>
</div>
<Input
id="password"
name="password"
type="password"
required
className="h-11"
/>
</div>
</div>
<Button formAction={login} className="h-11 w-full gap-2">
<LogIn className="h-4 w-4" />
Giriş yap
</Button>
</form>
}
secondaryAction={null}
footer={
setupState.available ? (
<div className="text-center text-sm">
İlk kurulumu yapmadın mı?{" "}
<Link
href="/register"
className="font-medium text-primary transition-colors hover:text-primary-hover"
>
Admin hesabını oluştur
</Link>
</div>
) : (
<span></span>
)
}
/>
</>
);
}