Deleted login page
This commit is contained in:
parent
aedd3b9f10
commit
e8c623aba5
@ -1,199 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import type React from "react"
|
||||
|
||||
import { useState } from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import Link from "next/link"
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import {
|
||||
Shield,
|
||||
ArrowLeft,
|
||||
Home,
|
||||
CheckCircle,
|
||||
} from "lucide-react"
|
||||
import AuthModal from "@/components/4nk/AuthModal"
|
||||
import MessageBus from "@/lib/4nk/MessageBus"
|
||||
import UserStore from "@/lib/4nk/UserStore"
|
||||
|
||||
export default function LoginPage() {
|
||||
const [isAuthModalOpen, setIsAuthModalOpen] = useState(false)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [isConnected, setIsConnected] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const router = useRouter()
|
||||
|
||||
const iframeUrl = process.env.NEXT_PUBLIC_4NK_IFRAME_URL || "https://dev3.4nkweb.com"
|
||||
|
||||
// Vérifier l'état de connexion au chargement
|
||||
useState(() => {
|
||||
const userStore = UserStore.getInstance()
|
||||
setIsConnected(userStore.isConnected())
|
||||
})
|
||||
|
||||
const handleLogin = () => {
|
||||
setIsAuthModalOpen(true)
|
||||
setError(null)
|
||||
}
|
||||
|
||||
const handleAuthSuccess = async () => {
|
||||
setIsAuthModalOpen(false)
|
||||
setIsConnected(true)
|
||||
|
||||
try {
|
||||
// Récupérer l'ID d'appairage après connexion
|
||||
const messageBus = MessageBus.getInstance(iframeUrl)
|
||||
await messageBus.isReady()
|
||||
const pairingId = await messageBus.getUserPairingId()
|
||||
|
||||
console.log("✅ Authentification 4NK réussie, ID d'appairage:", pairingId)
|
||||
|
||||
// Redirection vers le dashboard
|
||||
router.push("/dashboard")
|
||||
} catch (err) {
|
||||
console.error("Erreur lors de la récupération de l'ID d'appairage:", err)
|
||||
// Redirection quand même vers le dashboard
|
||||
router.push("/dashboard")
|
||||
}
|
||||
}
|
||||
|
||||
const handleAuthError = (errorMessage: string) => {
|
||||
setError(errorMessage)
|
||||
setIsAuthModalOpen(false)
|
||||
}
|
||||
|
||||
// Si déjà connecté, rediriger vers le dashboard
|
||||
if (isConnected) {
|
||||
router.push("/dashboard")
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 flex items-center justify-center p-4">
|
||||
<Card className="w-full max-w-md">
|
||||
<CardContent className="text-center py-8">
|
||||
<CheckCircle className="h-12 w-12 mx-auto text-green-600 mb-4" />
|
||||
<h2 className="text-xl font-semibold mb-2">Déjà connecté</h2>
|
||||
<p className="text-gray-600">Redirection vers le dashboard...</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 flex items-center justify-center p-4">
|
||||
<div className="w-full max-w-md space-y-6">
|
||||
{/* Lien de retour vers l'accueil */}
|
||||
<div className="text-center">
|
||||
<Link
|
||||
href="/"
|
||||
className="inline-flex items-center text-sm text-gray-600 hover:text-gray-900 transition-colors"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
Retour à l'accueil
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Logo et titre */}
|
||||
<div className="text-center">
|
||||
<div className="flex items-center justify-center mb-6">
|
||||
<Shield className="h-12 w-12 text-blue-600" />
|
||||
</div>
|
||||
<h1 className="text-3xl font-bold text-gray-900 mb-2">DocV</h1>
|
||||
<p className="text-gray-600">Gestion électronique de documents sécurisée</p>
|
||||
</div>
|
||||
|
||||
{/* Carte de connexion 4NK */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-center">
|
||||
<Shield className="h-8 w-8 mx-auto mb-4 text-blue-600" />
|
||||
Connexion sécurisée 4NK
|
||||
</CardTitle>
|
||||
<CardDescription className="text-center">
|
||||
Authentification cryptographique sans mot de passe
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{/* Description de la connexion 4NK */}
|
||||
<div className="bg-blue-50 border border-blue-200 rounded-lg p-4">
|
||||
<h3 className="font-semibold text-blue-900 mb-2">🔐 Authentification 4NK</h3>
|
||||
<ul className="text-sm text-blue-800 space-y-1">
|
||||
<li>• Aucun mot de passe requis</li>
|
||||
<li>• Identité cryptographique sécurisée</li>
|
||||
<li>• Chiffrement bout en bout</li>
|
||||
<li>• Protection par blockchain</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* Affichage des erreurs */}
|
||||
{error && (
|
||||
<div className="bg-red-50 border border-red-200 rounded-lg p-4">
|
||||
<p className="text-red-700 font-medium">Erreur de connexion :</p>
|
||||
<p className="text-red-600 text-sm">{error}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Bouton de connexion */}
|
||||
<Button
|
||||
onClick={handleLogin}
|
||||
className="w-full"
|
||||
size="lg"
|
||||
disabled={isLoading}
|
||||
>
|
||||
<Shield className="h-5 w-5 mr-2" />
|
||||
{isLoading ? "Connexion en cours..." : "Se connecter avec 4NK"}
|
||||
</Button>
|
||||
|
||||
{/* Informations sur l'iframe */}
|
||||
<div className="bg-gray-50 border border-gray-200 rounded-lg p-3">
|
||||
<p className="text-xs text-gray-600 text-center">
|
||||
<strong>URL d'authentification :</strong><br />
|
||||
{iframeUrl}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Badges de sécurité */}
|
||||
<div className="flex flex-wrap justify-center gap-2">
|
||||
<Badge variant="outline" className="bg-blue-50 text-blue-700 border-blue-200">
|
||||
<Shield className="h-3 w-3 mr-1" />
|
||||
Sécurisé 4NK
|
||||
</Badge>
|
||||
<Badge variant="outline" className="bg-green-50 text-green-700 border-green-200">
|
||||
Chiffrement bout en bout
|
||||
</Badge>
|
||||
<Badge variant="outline" className="bg-purple-50 text-purple-700 border-purple-200">
|
||||
Blockchain
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
{/* Lien vers l'espace public */}
|
||||
<div className="text-center">
|
||||
<Link
|
||||
href="/"
|
||||
className="inline-flex items-center text-sm text-blue-600 hover:text-blue-800 transition-colors"
|
||||
>
|
||||
<Home className="h-4 w-4 mr-2" />
|
||||
Découvrir DocV sans se connecter
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Informations légales */}
|
||||
<div className="text-center text-xs text-gray-500 space-y-1">
|
||||
<p>En vous connectant, vous acceptez nos conditions d'utilisation</p>
|
||||
<p>Vos données sont protégées par le chiffrement 4NK</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Modal d'authentification 4NK */}
|
||||
<AuthModal
|
||||
isOpen={isAuthModalOpen}
|
||||
onConnect={handleAuthSuccess}
|
||||
onClose={() => setIsAuthModalOpen(false)}
|
||||
iframeUrl={iframeUrl}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user