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:
@@ -3,9 +3,11 @@ FROM node:20-alpine AS builder
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Corepack applique la version de pnpm verrouillée dans package.json.
|
# Corepack applique la version de pnpm verrouillée dans package.json.
|
||||||
RUN npm install -g corepack@latest && corepack enable
|
RUN corepack enable
|
||||||
COPY . .
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
COPY patches ./patches
|
||||||
RUN pnpm install --frozen-lockfile
|
RUN pnpm install --frozen-lockfile
|
||||||
|
COPY . .
|
||||||
|
|
||||||
# Les variables Vite doivent être disponibles pendant la compilation frontend.
|
# Les variables Vite doivent être disponibles pendant la compilation frontend.
|
||||||
ARG VITE_APP_ID
|
ARG VITE_APP_ID
|
||||||
@@ -26,6 +28,9 @@ ENV VITE_APP_ID=${VITE_APP_ID} \
|
|||||||
VITE_APP_LOGO=${VITE_APP_LOGO}
|
VITE_APP_LOGO=${VITE_APP_LOGO}
|
||||||
RUN pnpm run build
|
RUN pnpm run build
|
||||||
|
|
||||||
|
# L’image d’exécution n’embarque ni TypeScript, ni Vite, ni les outils de test.
|
||||||
|
RUN pnpm prune --prod
|
||||||
|
|
||||||
FROM node:20-alpine AS runner
|
FROM node:20-alpine AS runner
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
<meta
|
<meta
|
||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, initial-scale=1.0, maximum-scale=1" />
|
content="width=device-width, initial-scale=1.0, maximum-scale=1" />
|
||||||
<link rel="icon" type="image/png" href="%VITE_APP_LOGO%" />
|
<link rel="icon" type="image/png" href="/itinova-logo.png" />
|
||||||
<link rel="apple-touch-icon" href="%VITE_APP_LOGO%" />
|
<link rel="apple-touch-icon" href="/itinova-logo.png" />
|
||||||
<title>%VITE_APP_TITLE%</title>
|
<title>Gestion des Formations Manager Itinova</title>
|
||||||
<!-- Add Google Fonts here, example:
|
<!-- Add Google Fonts here, example:
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { Route, Switch } from "wouter";
|
|||||||
import ErrorBoundary from "./components/ErrorBoundary";
|
import ErrorBoundary from "./components/ErrorBoundary";
|
||||||
import { ThemeProvider } from "./contexts/ThemeContext";
|
import { ThemeProvider } from "./contexts/ThemeContext";
|
||||||
import Home from "./pages/Home";
|
import Home from "./pages/Home";
|
||||||
import LoginChoice from "./pages/LoginChoice";
|
|
||||||
import AdminRapportPublicCible from "./pages/AdminRapportPublicCible";
|
import AdminRapportPublicCible from "./pages/AdminRapportPublicCible";
|
||||||
import Admin from "./pages/Admin";
|
import Admin from "./pages/Admin";
|
||||||
import AdminFormations from "./pages/AdminFormations";
|
import AdminFormations from "./pages/AdminFormations";
|
||||||
@@ -51,7 +50,7 @@ import CatalogueFormation from "./pages/CatalogueFormation";
|
|||||||
function Router() {
|
function Router() {
|
||||||
return (
|
return (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path={"/"} component={LoginChoice} />
|
<Route path={"/"} component={Login} />
|
||||||
<Route path={"/home"} component={Home} />
|
<Route path={"/home"} component={Home} />
|
||||||
<Route path={"/login"} component={Login} />
|
<Route path={"/login"} component={Login} />
|
||||||
<Route path={"/forgot-password"} component={ForgotPassword} />
|
<Route path={"/forgot-password"} component={ForgotPassword} />
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export { COOKIE_NAME, ONE_YEAR_MS } from "@shared/const";
|
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";
|
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,6 @@ import fs from "fs";
|
|||||||
import { type Server } from "http";
|
import { type Server } from "http";
|
||||||
import { nanoid } from "nanoid";
|
import { nanoid } from "nanoid";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { createServer as createViteServer } from "vite";
|
|
||||||
import viteConfig from "../../vite.config";
|
|
||||||
|
|
||||||
export async function setupVite(app: Express, server: Server) {
|
export async function setupVite(app: Express, server: Server) {
|
||||||
const serverOptions = {
|
const serverOptions = {
|
||||||
@@ -13,6 +11,14 @@ export async function setupVite(app: Express, server: Server) {
|
|||||||
allowedHosts: true as const,
|
allowedHosts: true as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Vite et sa configuration ne sont requis qu'en développement. Les spécificateurs dynamiques empêchent esbuild de les lier au serveur de production.
|
||||||
|
const vitePackage = "vite";
|
||||||
|
const viteConfigModule = "../../vite.config";
|
||||||
|
const [{ createServer: createViteServer }, { default: viteConfig }] = await Promise.all([
|
||||||
|
import(vitePackage),
|
||||||
|
import(viteConfigModule),
|
||||||
|
]);
|
||||||
|
|
||||||
const vite = await createViteServer({
|
const vite = await createViteServer({
|
||||||
...viteConfig,
|
...viteConfig,
|
||||||
configFile: false,
|
configFile: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user