import { redirect } from "next/navigation"

import { resolveRoleFromServerContext } from "@/lib/access-server"
import { isAdminRegistrationEnabled } from "@/lib/auth/server"

import { LoginForm } from "./login-form"

export const dynamic = "force-dynamic"

export default async function LoginPage() {
  const role = await resolveRoleFromServerContext()

  if (role) {
    redirect("/")
  }

  return <LoginForm allowRegistration={isAdminRegistrationEnabled()} />
}
