- Vos identifiants
- Adresse : ${escapeHtml(content.credentials.email)}
- Mot de passe temporaire :
- ${escapeHtml(content.credentials.password)}
+
+
+ Vos identifiants
+ Adresse : ${escapeHtml(content.credentials.email)}
+ Mot de passe temporaire :
+ ${escapeHtml(content.credentials.password)}
`
@@ -73,16 +80,16 @@ export const renderMail = (brand: Branding, content: MailContent): RenderedMail
const cta = content.cta
? `
-
+ `
: "";
const note = content.note
? `
- ${escapeHtml(content.note)}
`
+ ${escapeHtml(content.note)}
`
: "";
const html = `
@@ -90,32 +97,39 @@ export const renderMail = (brand: Branding, content: MailContent): RenderedMail
-
+
+
${escapeHtml(content.heading)}
-
-${escapeHtml(content.preview)}
-
+
+${escapeHtml(content.preview)}
+
-
-
-
-
- ${escapeHtml(brand.appName)}
-
+
+
+ ${escapeHtml(brand.appName)}
-
- ${escapeHtml(content.heading)}
- ${escapeHtml(content.intro)}
+
+ ${escapeHtml(content.heading)}
+ ${escapeHtml(content.intro)}
+
+
${paragraphs}${credentials}${cta}${note}
-
-
- Message automatique : merci de ne pas repondre a cet e-mail.
- ${escapeHtml(brand.footer)}
+
+
+
+
+ Message automatique : merci de ne pas repondre a cet e-mail.
+ ${escapeHtml(brand.footer)}
+
+
+
+
+
+
- ${escapeHtml(brand.appName)} — ${escapeHtml(brand.origin.replace(/^https?:\/\//, ""))}
diff --git a/backend/src/lib/mail.ts b/backend/src/lib/mail.ts
index ff9d164..48938a7 100644
--- a/backend/src/lib/mail.ts
+++ b/backend/src/lib/mail.ts
@@ -1,5 +1,7 @@
+import { readFileSync } from "node:fs";
import { createTransport, type Transporter } from "nodemailer";
import type { Config } from "./config.js";
+import { LOGO_CID } from "./mail-template.js";
/**
* Envoi de courriel via SMTP.
@@ -9,6 +11,20 @@ import type { Config } from "./config.js";
* laisser une reinitialisation de mot de passe silencieusement sans effet.
*/
+/**
+ * Logo embarque dans les messages. Le chemin remonte depuis `src/lib` ou
+ * `dist/lib` vers `backend/src/assets/logo.png`, present dans l'image.
+ */
+const LOGO_PATH = new URL("../../src/assets/logo.png", import.meta.url);
+
+const loadLogo = (): Buffer | null => {
+ try {
+ return readFileSync(LOGO_PATH);
+ } catch {
+ return null;
+ }
+};
+
export interface MailMessage {
to: string;
subject: string;
@@ -33,14 +49,22 @@ export const createMailer = (config: Config): Mailer => {
disableUrlAccess: true,
});
+ // Logo embarque une seule fois. `MAIL_LOGO_URL` le remplace par une image
+ // distante : dans ce cas on n'attache rien.
+ const logo = config.MAIL_LOGO_URL ? null : loadLogo();
+
return {
send: async (message) => {
+ const inlineLogo = logo !== null && message.html?.includes(`cid:${LOGO_CID}`) === true;
await transport.sendMail({
from: config.SMTP_FROM,
to: message.to,
subject: message.subject,
text: message.text,
...(message.html ? { html: message.html } : {}),
+ ...(inlineLogo
+ ? { attachments: [{ filename: "logo.png", content: logo, cid: LOGO_CID }] }
+ : {}),
});
},
};
diff --git a/docs/api.md b/docs/api.md
index 6a9da17..3b31abc 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -115,9 +115,12 @@ par tous les membres authentifiés, en écriture pour son propriétaire.
## Courriels
Les messages sortants sont construits par `backend/src/lib/mail-template.ts` :
-gabarit HTML aux couleurs de l'app (`#b71c1c`), logo (`MAIL_LOGO_URL`, défaut
-`PUBLIC_ORIGIN/logo.png`), bouton d'action et mention **ne pas répondre**. Un
-repli texte accompagne chaque envoi.
+gabarit HTML aux couleurs de l'app (`#b71c1c`), logo, bouton d'action et mention
+**ne pas répondre**. Un repli texte accompagne chaque envoi.
+
+Le logo `backend/src/assets/logo.png` est **embarqué** dans le message (pièce
+jointe `cid`), donc visible même quand le client bloque les images distantes.
+`MAIL_LOGO_URL` force une image distante à la place.
Points d'envoi : réinitialisation du mot de passe, changement d'adresse, et
**notification au nouvel utilisateur** à la création d'un compte admin
diff --git a/docs/deployment.md b/docs/deployment.md
index c452d73..fedae44 100644
--- a/docs/deployment.md
+++ b/docs/deployment.md
@@ -35,7 +35,7 @@ pose problème (`backend/src/lib/config.ts`).
| `SMTP_USER` / `SMTP_PASSWORD` | authentification (vides = relais local) | vide |
| `SMTP_FROM` | adresse d'expédition | — |
| `SMTP_SECURE` | TLS implicite (port 465) | `false` |
-| `MAIL_LOGO_URL` | logo des courriels (défaut `PUBLIC_ORIGIN/logo.png`) | vide |
+| `MAIL_LOGO_URL` | logo distant des courriels (sinon logo embarqué `backend/src/assets/logo.png`) | vide |
| `RATE_LIMIT_LOGIN_MAX` | tentatives par fenêtre | `10` |
| `RATE_LIMIT_LOGIN_WINDOW_MS` | largeur de fenêtre | `60000` |
| `LOG_LEVEL` | `silent…debug` | `info` |
diff --git a/frontend/index.html b/frontend/index.html
index 86b8080..a0ab49b 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -7,8 +7,8 @@
CoHaiSe Cloud
-
-
+
+
diff --git a/frontend/public/icon.png b/frontend/public/icon.png
new file mode 100644
index 0000000..f34c330
Binary files /dev/null and b/frontend/public/icon.png differ
diff --git a/frontend/public/logo.png b/frontend/public/logo.png
deleted file mode 100644
index 59bda20..0000000
Binary files a/frontend/public/logo.png and /dev/null differ
diff --git a/frontend/src/components/AppShell.tsx b/frontend/src/components/AppShell.tsx
index 98ae814..80932f9 100644
--- a/frontend/src/components/AppShell.tsx
+++ b/frontend/src/components/AppShell.tsx
@@ -58,6 +58,11 @@ export const AppShell = () => {
const brand = (
setMenuOpen(false)}>
+
CoHaiSe
diff --git a/frontend/src/components/confirm.tsx b/frontend/src/components/confirm.tsx
new file mode 100644
index 0000000..b888262
--- /dev/null
+++ b/frontend/src/components/confirm.tsx
@@ -0,0 +1,85 @@
+import {
+ createContext,
+ useCallback,
+ useContext,
+ useState,
+ type ReactNode,
+} from "react";
+import { Button } from "../ui/index.js";
+import { Modal } from "./feedback.js";
+
+export interface ConfirmOptions {
+ /** Titre de la modale. */
+ title?: string;
+ /** Corps du message ; accepte du balisage pour mettre un nom en valeur. */
+ message: ReactNode;
+ confirmLabel?: string;
+ cancelLabel?: string;
+ /** `danger` reserve l'action a une operation destructive. */
+ tone?: "default" | "danger";
+}
+
+type ConfirmFn = (options: ConfirmOptions) => Promise;
+
+interface PendingConfirm {
+ options: ConfirmOptions;
+ resolve: (value: boolean) => void;
+}
+
+const ConfirmContext = createContext(null);
+
+/**
+ * Remplace `window.confirm` par une modale maison aux couleurs de l'app.
+ * `useConfirm()` renvoie une promesse resolue a `true` (confirme) ou `false`.
+ */
+export const ConfirmProvider = ({ children }: { children: ReactNode }) => {
+ const [pending, setPending] = useState(null);
+
+ const confirm = useCallback(
+ (options) => new Promise((resolve) => setPending({ options, resolve })),
+ [],
+ );
+
+ const answer = (value: boolean) => {
+ if (pending) pending.resolve(value);
+ setPending(null);
+ };
+
+ const tone = pending?.options.tone ?? "default";
+
+ return (
+
+ {children}
+ answer(false)}
+ >
+
+
+ {pending?.options.message}
+
+
+ answer(false)}>
+ {pending?.options.cancelLabel ?? "Annuler"}
+
+ answer(true)}
+ >
+ {pending?.options.confirmLabel ?? "Confirmer"}
+
+
+
+
+
+ );
+};
+
+export const useConfirm = (): ConfirmFn => {
+ const context = useContext(ConfirmContext);
+ if (!context) throw new Error("useConfirm doit etre utilise sous ConfirmProvider");
+ return context;
+};
diff --git a/frontend/src/components/feedback.tsx b/frontend/src/components/feedback.tsx
index 5e3639f..d16fe25 100644
--- a/frontend/src/components/feedback.tsx
+++ b/frontend/src/components/feedback.tsx
@@ -1,4 +1,4 @@
-import type { ReactNode } from "react";
+import { useEffect, type ReactNode } from "react";
import { cn } from "../ui/index.js";
import { CloseIcon } from "./icons.js";
@@ -11,13 +11,27 @@ export const Modal = ({
open: boolean;
title: string;
onClose: () => void;
- children: React.ReactNode;
+ children: ReactNode;
}) => {
+ useEffect(() => {
+ if (!open) return;
+ const onKeyDown = (event: KeyboardEvent) => {
+ if (event.key === "Escape") onClose();
+ };
+ window.addEventListener("keydown", onKeyDown);
+ const previousOverflow = document.body.style.overflow;
+ document.body.style.overflow = "hidden";
+ return () => {
+ window.removeEventListener("keydown", onKeyDown);
+ document.body.style.overflow = previousOverflow;
+ };
+ }, [open, onClose]);
+
if (!open) return null;
return (
@@ -25,7 +39,7 @@ export const Modal = ({
role="dialog"
aria-modal="true"
aria-label={title}
- className="relative w-full max-w-md rounded-lg border border-border bg-surface p-4 shadow-lg"
+ className="animate-panel-in relative w-full max-w-md rounded-lg border border-border bg-surface p-4 shadow-lg"
>
@@ -35,7 +49,7 @@ export const Modal = ({
type="button"
onClick={onClose}
aria-label="Fermer"
- className="text-muted-foreground transition-colors hover:text-foreground"
+ className="rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
>
diff --git a/frontend/src/components/icons.tsx b/frontend/src/components/icons.tsx
index 3c5e477..33b555b 100644
--- a/frontend/src/components/icons.tsx
+++ b/frontend/src/components/icons.tsx
@@ -145,6 +145,12 @@ export const CloseIcon = (props: IconProps) => (
);
+export const ArrowLeftIcon = (props: IconProps) => (
+
+
+
+);
+
export const PenIcon = (props: IconProps) => (
diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx
index 0ebf8f4..a97634f 100644
--- a/frontend/src/main.tsx
+++ b/frontend/src/main.tsx
@@ -3,6 +3,7 @@ import { createRoot } from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import { App } from "./App.js";
import { SessionProvider } from "./lib/session.js";
+import { ConfirmProvider } from "./components/confirm.js";
import "./styles/index.css";
const container = document.getElementById("root");
@@ -15,7 +16,9 @@ createRoot(container).render(
-
+
+
+
,
diff --git a/frontend/src/pages/Admin.tsx b/frontend/src/pages/Admin.tsx
index ac6f1db..893a5f3 100644
--- a/frontend/src/pages/Admin.tsx
+++ b/frontend/src/pages/Admin.tsx
@@ -10,6 +10,7 @@ import {
type StorageLocation,
} from "../lib/api.js";
import { Alert, Badge, EmptyState, Modal, PageHeader } from "../components/feedback.js";
+import { useConfirm } from "../components/confirm.js";
import { IconAction } from "../components/IconAction.js";
import {
ActivityIcon,
@@ -38,6 +39,7 @@ const StatCard = ({ label, value }: { label: string; value: string }) => (
);
export const AdminUsers = () => {
+ const confirm = useConfirm();
const [users, setUsers] = useState(null);
const [stats, setStats] = useState(null);
const [q, setQ] = useState("");
@@ -95,7 +97,18 @@ export const AdminUsers = () => {
};
const removeUser = async (user: AdminUser) => {
- if (!window.confirm(`Supprimer définitivement ${user.email} ?`)) return;
+ const ok = await confirm({
+ title: "Supprimer le membre",
+ message: (
+ <>
+ Supprimer définitivement {user.email} {" "}
+ ainsi que ses fichiers ? Cette action est irréversible.
+ >
+ ),
+ confirmLabel: "Supprimer",
+ tone: "danger",
+ });
+ if (!ok) return;
setBusy(user.id);
setError(null);
try {
diff --git a/frontend/src/pages/Browser.tsx b/frontend/src/pages/Browser.tsx
index a46afb5..06e42b1 100644
--- a/frontend/src/pages/Browser.tsx
+++ b/frontend/src/pages/Browser.tsx
@@ -9,6 +9,7 @@ import {
} from "../lib/api.js";
import { useSession } from "../lib/session.js";
import { Alert, Badge, EmptyState, PageHeader } from "../components/feedback.js";
+import { useConfirm } from "../components/confirm.js";
import { IconAction } from "../components/IconAction.js";
import {
CreateFolderDialog,
@@ -17,6 +18,7 @@ import {
ShareDialog,
} from "../components/dialogs.js";
import {
+ ArrowLeftIcon,
DownloadIcon,
FileIcon,
FolderIcon,
@@ -48,6 +50,7 @@ const isImage = (file: UploadedFile): boolean =>
export const Browser = () => {
const { user, refresh } = useSession();
+ const confirm = useConfirm();
const [path, setPath] = useState([{ id: null, name: "Racine" }]);
const [folders, setFolders] = useState([]);
const [files, setFiles] = useState([]);
@@ -111,7 +114,18 @@ export const Browser = () => {
const removeTarget = async (target: Target) => {
const label = target.type === "folder" ? "ce dossier" : "ce fichier";
- if (!window.confirm(`Placer ${label} dans la corbeille ?`)) return;
+ const ok = await confirm({
+ title: "Mettre à la corbeille",
+ message: (
+ <>
+ Placer {target.name} ({label}) dans la
+ corbeille ?
+ >
+ ),
+ confirmLabel: "Corbeille",
+ tone: "danger",
+ });
+ if (!ok) return;
setRemoving(target.id);
setError(null);
try {
@@ -153,32 +167,45 @@ export const Browser = () => {
description="Vos dossiers et fichiers. Envoyez un fichier ou créez un dossier."
/>
-
-
- {path.map((crumb, index) => (
-
- {index > 0 ? (
-
- /
-
- ) : null}
- {index === path.length - 1 ? (
-
- {crumb.name}
-
- ) : (
- goTo(index)}
- className="text-muted-foreground underline-offset-2 transition-colors hover:text-foreground hover:underline"
- >
- {crumb.name}
-
- )}
-
- ))}
-
-
+
+ {path.length > 1 ? (
+
goTo(path.length - 2)}
+ className="inline-flex items-center gap-1.5 rounded-sm border border-border-control bg-surface px-2.5 py-1.5 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-foreground transition-colors duration-fast hover:bg-surface-hover focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
+ >
+
+ Retour
+
+ ) : null}
+
+
+
+ {path.map((crumb, index) => (
+
+ {index > 0 ? (
+
+ /
+
+ ) : null}
+ {index === path.length - 1 ? (
+
+ {crumb.name}
+
+ ) : (
+ goTo(index)}
+ className="text-muted-foreground underline-offset-2 transition-colors hover:text-foreground hover:underline"
+ >
+ {crumb.name}
+
+ )}
+
+ ))}
+
+
+
diff --git a/frontend/src/pages/ChangePassword.tsx b/frontend/src/pages/ChangePassword.tsx
index b9cb2b7..0ca1808 100644
--- a/frontend/src/pages/ChangePassword.tsx
+++ b/frontend/src/pages/ChangePassword.tsx
@@ -37,12 +37,21 @@ export const ChangePassword = () => {
-
- CoHaiSe
-
-
- Nouveau mot de passe
-
+
+
+
+
+ CoHaiSe
+
+
+ Nouveau mot de passe
+
+
+
Bienvenue {user?.first_name ?? ""}. Ce mot de passe a été défini par un
administrateur : choisissez le vôtre.
diff --git a/frontend/src/pages/ConfirmEmail.tsx b/frontend/src/pages/ConfirmEmail.tsx
index ea5f047..77529da 100644
--- a/frontend/src/pages/ConfirmEmail.tsx
+++ b/frontend/src/pages/ConfirmEmail.tsx
@@ -37,12 +37,21 @@ export const ConfirmEmail = () => {
-
- CoHaiSe
-
-
- Changement d'adresse
-
+
+
+
+
+ CoHaiSe
+
+
+ Changement d'adresse
+
+
+
diff --git a/frontend/src/pages/ForgotPassword.tsx b/frontend/src/pages/ForgotPassword.tsx
index 1f2a39b..fd832eb 100644
--- a/frontend/src/pages/ForgotPassword.tsx
+++ b/frontend/src/pages/ForgotPassword.tsx
@@ -28,12 +28,21 @@ export const ForgotPassword = () => {
-
- CoHaiSe
-
-
- Mot de passe oublié
-
+
+
+
+
+ CoHaiSe
+
+
+ Mot de passe oublié
+
+
+
diff --git a/frontend/src/pages/Login.tsx b/frontend/src/pages/Login.tsx
index d07f237..f5e09de 100644
--- a/frontend/src/pages/Login.tsx
+++ b/frontend/src/pages/Login.tsx
@@ -33,12 +33,21 @@ export const Login = () => {