"use client"; import React from "react"; import { useAuth } from "@/contexts/auth-context"; import { LoginButton } from "@/components/auth/login-button"; import { GitHubIcon } from "@/components/icons/github-icon"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; import { LucideIcon } from "lucide-react"; import { useRouter, useSearchParams } from "next/navigation"; import { useEffect } from "react"; interface AuthProvider { id: string; name: string; icon: LucideIcon; loginPath: string; buttonColor?: string; } interface LoginPageProps { backendUrl: string; } export function LoginPage({ backendUrl }: LoginPageProps) { const { isAuthenticated, isLoading } = useAuth(); const router = useRouter(); const searchParams = useSearchParams(); const error = searchParams.get("error"); // Define available auth providers const authProviders: AuthProvider[] = [ { id: "github", name: "GitHub", icon: GitHubIcon as LucideIcon, loginPath: `${backendUrl}/auth/github/login`, buttonColor: "bg-gray-900 hover:bg-gray-800 text-white", }, // Future providers can be added here ]; useEffect(() => { if (!isLoading && isAuthenticated) { router.push("/"); } }, [isAuthenticated, isLoading, router]); if (isLoading) { return (
Loading...
); } return (
Welcome to Llama Stack {error === "auth_not_configured" ? "Authentication is not configured on this server" : "Sign in to access your logs and resources"} {error !== "auth_not_configured" && ( <> {authProviders.length > 1 && ( <>
Continue with
)}
{authProviders.map((provider) => ( ))}
)}
); }