feat: logo et favicon, confirmation modale, fil d'ariane, e-mails sombres
PR — Ouverture automatique / create-pr (push) Successful in 2s

- logo embarque dans les e-mails (CID) et gabarit repense en mode sombre
- favicon multi-tailles + icone PNG, logo a gauche du titre (app et auth)
- modale de confirmation animee a la place de window.confirm
- bouton retour et fil d'ariane dans l'explorateur
This commit is contained in:
2026-10-16 12:58:51 +02:00
parent 739bc26b43
commit 60f1c50cdf
25 changed files with 423 additions and 112 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

+2 -2
View File
@@ -60,8 +60,8 @@ const schema = z.object({
SMTP_FROM: z.string().min(3),
SMTP_SECURE: bool(false),
/**
* Logo des courriels. Par defaut celui publie par le front
* (`PUBLIC_ORIGIN/logo.png`) ; l'URL doit etre joignable depuis Internet.
* Logo des courriels. Par defaut le logo embarque (`backend/src/assets/logo.png`,
* joint au message) ; renseigner une URL pour forcer une image distante.
*/
MAIL_LOGO_URL: z
.string()
+43 -29
View File
@@ -15,10 +15,17 @@ export interface Branding {
footer: string;
}
/**
* Identifiant de la piece jointe du logo. Le logo est embarque dans le message
* (voir `mail.ts`) : l'image s'affiche meme si le client bloque les ressources
* distantes. `MAIL_LOGO_URL` force une image distante a la place.
*/
export const LOGO_CID = "cohaise-logo";
export const branding = (config: Config): Branding => ({
appName: "CoHaiSe Cloud",
origin: config.PUBLIC_ORIGIN,
logoUrl: config.MAIL_LOGO_URL ?? new URL("/logo.png", config.PUBLIC_ORIGIN).toString(),
logoUrl: config.MAIL_LOGO_URL ?? `cid:${LOGO_CID}`,
color: "#b71c1c",
footer: config.SMTP_FROM,
});
@@ -54,18 +61,18 @@ export const renderMail = (brand: Branding, content: MailContent): RenderedMail
const paragraphs = (content.paragraphs ?? [])
.map(
(paragraph) =>
`<p style="margin:0 0 16px;font-size:15px;line-height:1.6;color:#3f3f46;">${escapeHtml(paragraph)}</p>`,
`<p style="margin:0 0 16px;font-size:15px;line-height:1.6;color:#c9c2c2;text-align:center;">${escapeHtml(paragraph)}</p>`,
)
.join("");
const credentials = content.credentials
? `
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:0 0 24px;background:#fafafa;border:1px solid #e4e4e7;border-radius:10px;">
<tr><td style="padding:16px 18px;font-family:${FONT};">
<p style="margin:0 0 10px;font:600 12px ${FONT};letter-spacing:.04em;text-transform:uppercase;color:#71717a;">Vos identifiants</p>
<p style="margin:0 0 6px;font:400 14px ${FONT};color:#3f3f46;">Adresse : <strong style="color:#18181b;">${escapeHtml(content.credentials.email)}</strong></p>
<p style="margin:0;font:400 14px ${FONT};color:#3f3f46;">Mot de passe temporaire :
<span style="font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:14px;background:#ffffff;border:1px solid #e4e4e7;border-radius:6px;padding:2px 8px;color:#18181b;">${escapeHtml(content.credentials.password)}</span>
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:0 auto 26px;max-width:420px;background:#1b1212;border:1px solid #332222;border-radius:10px;">
<tr><td style="padding:16px 18px;font-family:${FONT};text-align:left;">
<p style="margin:0 0 10px;font:600 12px ${FONT};letter-spacing:.04em;text-transform:uppercase;color:#9c9292;">Vos identifiants</p>
<p style="margin:0 0 6px;font:400 14px ${FONT};color:#c9c2c2;">Adresse : <strong style="color:#f7f5f5;">${escapeHtml(content.credentials.email)}</strong></p>
<p style="margin:0;font:400 14px ${FONT};color:#c9c2c2;">Mot de passe temporaire :
<span style="font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:14px;background:#241818;border:1px solid #3a2828;border-radius:6px;padding:2px 8px;color:#f7f5f5;">${escapeHtml(content.credentials.password)}</span>
</p>
</td></tr>
</table>`
@@ -73,16 +80,16 @@ export const renderMail = (brand: Branding, content: MailContent): RenderedMail
const cta = content.cta
? `
<table role="presentation" cellpadding="0" cellspacing="0" style="margin:0 0 24px;">
<table role="presentation" cellpadding="0" cellspacing="0" align="center" style="margin:0 auto 26px;">
<tr><td align="center" style="background:${brand.color};border-radius:10px;">
<a href="${escapeHtml(content.cta.url)}" style="display:inline-block;padding:13px 30px;font:600 15px ${FONT};color:#ffffff;text-decoration:none;">${escapeHtml(content.cta.label)}</a>
<a href="${escapeHtml(content.cta.url)}" style="display:inline-block;padding:14px 32px;font:600 15px ${FONT};color:#ffffff;text-decoration:none;">${escapeHtml(content.cta.label)}</a>
</td></tr>
</table>`
: "";
const note = content.note
? `
<p style="margin:0;font:400 13px ${FONT};line-height:1.6;color:#71717a;">${escapeHtml(content.note)}</p>`
<p style="margin:0;font:400 13px ${FONT};line-height:1.6;color:#8a8282;text-align:center;">${escapeHtml(content.note)}</p>`
: "";
const html = `<!doctype html>
@@ -90,32 +97,39 @@ export const renderMail = (brand: Branding, content: MailContent): RenderedMail
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="color-scheme" content="light only">
<meta name="color-scheme" content="dark only">
<meta name="supported-color-schemes" content="dark only">
<title>${escapeHtml(content.heading)}</title>
</head>
<body style="margin:0;padding:0;background:#f4f4f5;">
<div style="display:none;max-height:0;overflow:hidden;opacity:0;color:#f4f4f5;">${escapeHtml(content.preview)}</div>
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;padding:32px 12px;">
<body style="margin:0;padding:0;background:#050000;">
<div style="display:none;max-height:0;overflow:hidden;opacity:0;color:#050000;">${escapeHtml(content.preview)}</div>
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#050000;padding:32px 12px;">
<tr><td align="center">
<table role="presentation" width="560" cellpadding="0" cellspacing="0" style="width:100%;max-width:560px;background:#ffffff;border:1px solid #e4e4e7;border-radius:14px;overflow:hidden;">
<tr><td style="background:${brand.color};padding:18px 28px;">
<a href="${escapeHtml(brand.origin)}" style="text-decoration:none;">
<img src="${escapeHtml(brand.logoUrl)}" width="34" height="34" alt="" style="vertical-align:middle;border:0;border-radius:9px;background:#ffffff;">
<span style="vertical-align:middle;margin-left:12px;font:600 17px ${FONT};color:#ffffff;">${escapeHtml(brand.appName)}</span>
</a>
<table role="presentation" width="560" cellpadding="0" cellspacing="0" style="width:100%;max-width:560px;background:#140d0d;border:1px solid #2a1c1c;border-radius:14px;overflow:hidden;">
<tr><td style="background:${brand.color};padding:17px 28px;text-align:center;">
<span style="font:700 14px ${FONT};letter-spacing:.18em;text-transform:uppercase;color:#ffffff;">${escapeHtml(brand.appName)}</span>
</td></tr>
<tr><td style="padding:32px 28px 6px;font-family:${FONT};">
<h1 style="margin:0 0 16px;font:600 21px ${FONT};line-height:1.3;color:#18181b;">${escapeHtml(content.heading)}</h1>
<p style="margin:0 0 16px;font:400 15px ${FONT};line-height:1.6;color:#3f3f46;">${escapeHtml(content.intro)}</p>
<tr><td style="padding:40px 30px 6px;font-family:${FONT};text-align:center;">
<h1 style="margin:0 0 18px;font:700 28px ${FONT};line-height:1.25;color:#f7f5f5;">${escapeHtml(content.heading)}</h1>
<p style="margin:0 0 28px;font:400 15px ${FONT};line-height:1.65;color:#c9c2c2;">${escapeHtml(content.intro)}</p>
</td></tr>
<tr><td style="padding:0 30px 14px;font-family:${FONT};text-align:center;">
${paragraphs}${credentials}${cta}${note}
</td></tr>
<tr><td style="padding:20px 28px 28px;font-family:${FONT};">
<hr style="border:0;border-top:1px solid #e4e4e7;margin:0 0 16px;">
<p style="margin:0 0 4px;font:400 12px ${FONT};line-height:1.6;color:#71717a;">Message automatique : merci de ne pas repondre a cet e-mail.</p>
<p style="margin:0;font:400 12px ${FONT};line-height:1.6;color:#a1a1aa;">${escapeHtml(brand.footer)}</p>
<tr><td style="padding:20px 28px 24px;background:#0d0808;border-top:1px solid #2a1c1c;">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td style="vertical-align:middle;font-family:${FONT};">
<p style="margin:0 0 4px;font:400 12px ${FONT};line-height:1.6;color:#8a8282;">Message automatique : merci de ne pas repondre a cet e-mail.</p>
<p style="margin:0;font:400 12px ${FONT};line-height:1.6;color:#8a8282;">${escapeHtml(brand.footer)}</p>
</td>
<td align="right" style="vertical-align:middle;padding-left:16px;">
<img src="${escapeHtml(brand.logoUrl)}" width="44" height="44" alt="" style="display:block;border:0;border-radius:10px;background:#ffffff;">
</td>
</tr>
</table>
</td></tr>
</table>
<p style="margin:18px 0 0;font:400 12px ${FONT};color:#a1a1aa;">${escapeHtml(brand.appName)} — <a href="${escapeHtml(brand.origin)}" style="color:#a1a1aa;">${escapeHtml(brand.origin.replace(/^https?:\/\//, ""))}</a></p>
</td></tr>
</table>
</body>
+24
View File
@@ -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 }] }
: {}),
});
},
};