feat: ouvrir directement la connexion locale
All checks were successful
Validation applicative / TypeScript, tests et build (push) Successful in 5m10s
All checks were successful
Validation applicative / TypeScript, tests et build (push) Successful in 5m10s
This commit is contained in:
@@ -6,9 +6,9 @@
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1" />
|
||||
<link rel="icon" type="image/png" href="%VITE_APP_LOGO%" />
|
||||
<link rel="apple-touch-icon" href="%VITE_APP_LOGO%" />
|
||||
<title>%VITE_APP_TITLE%</title>
|
||||
<link rel="icon" type="image/png" href="/itinova-logo.png" />
|
||||
<link rel="apple-touch-icon" href="/itinova-logo.png" />
|
||||
<title>Gestion des Formations Manager Itinova</title>
|
||||
<!-- Add Google Fonts here, example:
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Route, Switch } from "wouter";
|
||||
import ErrorBoundary from "./components/ErrorBoundary";
|
||||
import { ThemeProvider } from "./contexts/ThemeContext";
|
||||
import Home from "./pages/Home";
|
||||
import LoginChoice from "./pages/LoginChoice";
|
||||
import AdminRapportPublicCible from "./pages/AdminRapportPublicCible";
|
||||
import Admin from "./pages/Admin";
|
||||
import AdminFormations from "./pages/AdminFormations";
|
||||
@@ -51,7 +50,7 @@ import CatalogueFormation from "./pages/CatalogueFormation";
|
||||
function Router() {
|
||||
return (
|
||||
<Switch>
|
||||
<Route path={"/"} component={LoginChoice} />
|
||||
<Route path={"/"} component={Login} />
|
||||
<Route path={"/home"} component={Home} />
|
||||
<Route path={"/login"} component={Login} />
|
||||
<Route path={"/forgot-password"} component={ForgotPassword} />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export { COOKIE_NAME, ONE_YEAR_MS } from "@shared/const";
|
||||
|
||||
export const APP_TITLE = import.meta.env.VITE_APP_TITLE || "App";
|
||||
// Les déploiements autonomes ne reçoivent pas systématiquement les variables Vite de la plateforme.
|
||||
export const APP_TITLE = import.meta.env.VITE_APP_TITLE || "Gestion des Formations Manager Itinova";
|
||||
|
||||
export const APP_LOGO = "/itinova-logo.png";
|
||||
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
import { useLocation } from "wouter";
|
||||
import { useAuth } from "@/_core/hooks/useAuth";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { APP_LOGO, APP_TITLE, getLoginUrl } from "@/const";
|
||||
import { KeyRound, Shield } from "lucide-react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function LoginChoice() {
|
||||
const [, setLocation] = useLocation();
|
||||
const { user, loading, isAuthenticated } = useAuth();
|
||||
|
||||
// Rediriger les utilisateurs déjà connectés vers le tableau de bord
|
||||
useEffect(() => {
|
||||
if (!loading && isAuthenticated && user?.role === 'admin') {
|
||||
setLocation('/admin');
|
||||
}
|
||||
}, [loading, isAuthenticated, user?.role, setLocation]);
|
||||
|
||||
const handleManusLogin = () => {
|
||||
window.location.href = getLoginUrl();
|
||||
};
|
||||
|
||||
const handleLocalLogin = () => {
|
||||
setLocation("/login");
|
||||
};
|
||||
|
||||
// Afficher un loader pendant la vérification de l'authentification
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center">
|
||||
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"></div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Ne pas afficher la page si l'utilisateur est déjà connecté (redirection en cours)
|
||||
if (isAuthenticated && user?.role === 'admin') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-blue-50 to-indigo-100 p-4">
|
||||
<Card className="w-full max-w-2xl">
|
||||
<CardHeader className="space-y-4">
|
||||
<div className="flex justify-center">
|
||||
<img src={APP_LOGO} alt="Logo" className="h-20 w-auto" />
|
||||
</div>
|
||||
<div className="text-center">
|
||||
<CardTitle className="page-title">{APP_TITLE}</CardTitle>
|
||||
<CardDescription className="mt-3 text-base">
|
||||
Choisissez votre méthode de connexion
|
||||
</CardDescription>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
{/* Connexion Manus OAuth */}
|
||||
<Card className="border-2 hover:border-primary transition-colors cursor-pointer group" onClick={handleManusLogin}>
|
||||
<CardHeader className="text-center pb-4">
|
||||
<div className="flex justify-center mb-4">
|
||||
<div className="p-4 bg-blue-100 rounded-full group-hover:bg-blue-200 transition-colors">
|
||||
<Shield className="h-12 w-12 text-blue-600" />
|
||||
</div>
|
||||
</div>
|
||||
<CardTitle className="text-xl">Connexion Manus</CardTitle>
|
||||
<CardDescription className="mt-2">
|
||||
Utilisez votre compte Manus (Google, Microsoft, Apple)
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Button
|
||||
className="w-full"
|
||||
size="lg"
|
||||
onClick={handleManusLogin}
|
||||
>
|
||||
Se connecter avec Manus
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Connexion Locale */}
|
||||
<Card className="border-2 hover:border-primary transition-colors cursor-pointer group" onClick={handleLocalLogin}>
|
||||
<CardHeader className="text-center pb-4">
|
||||
<div className="flex justify-center mb-4">
|
||||
<div className="p-4 bg-green-100 rounded-full group-hover:bg-green-200 transition-colors">
|
||||
<KeyRound className="h-12 w-12 text-green-600" />
|
||||
</div>
|
||||
</div>
|
||||
<CardTitle className="text-xl">Connexion Locale</CardTitle>
|
||||
<CardDescription className="mt-2">
|
||||
Utilisez votre identifiant et mot de passe
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Button
|
||||
className="w-full"
|
||||
variant="outline"
|
||||
size="lg"
|
||||
onClick={handleLocalLogin}
|
||||
>
|
||||
Se connecter localement
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="mt-6 text-center text-sm text-gray-600">
|
||||
<p>Vous n'avez pas de compte ?</p>
|
||||
<p className="mt-1">Contactez l'administrateur</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user