import { useState, useEffect } from "react"; import { useLocation } from "wouter"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { Label } from "@/components/ui/label"; import { useToast } from "@/hooks/use-toast"; import { apiRequest } from "@/lib/queryClient"; import { Lock, User, Sparkles } from "lucide-react"; export default function Login() { const [, setLocation] = useLocation(); const { toast } = useToast(); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [isLoading, setIsLoading] = useState(false); const [showDefaultPassword, setShowDefaultPassword] = useState(false); useEffect(() => { const checkDefaultPassword = async () => { try { const response = await fetch("/api/auth/default-password-status"); const data = await response.json(); setShowDefaultPassword(data.isDefault === true); } catch (error) { console.error("Error checking default password status:", error); } }; checkDefaultPassword(); }, []); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); try { const response = await apiRequest("POST", "/api/auth/login", { username, password }); const data = await response.json(); toast({ title: "Connexion réussie", description: `Bienvenue ${data.username}`, }); setLocation("/"); } catch (error: any) { toast({ variant: "destructive", title: "Erreur de connexion", description: error.message || "Nom d'utilisateur ou mot de passe incorrect", }); } finally { setIsLoading(false); } }; return (
Social Flow Connectez-vous à votre compte pour gérer vos publications
setUsername(e.target.value)} className="pl-12 h-12 rounded-xl bg-muted/30 border-border/50 focus:border-primary/50" required disabled={isLoading} data-testid="input-username" />
setPassword(e.target.value)} className="pl-12 h-12 rounded-xl bg-muted/30 border-border/50 focus:border-primary/50" required disabled={isLoading} data-testid="input-password" />
{showDefaultPassword && (

Identifiants par défaut :

admin / admin

⚠️ Changez ce mot de passe après la première connexion

)}
); }