diff --git a/public/app.css b/public/app.css
index f6821a1..81d212f 100644
--- a/public/app.css
+++ b/public/app.css
@@ -28,6 +28,12 @@ a { color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.login { max-width: 380px; margin: 12vh auto; text-align: center; }
+.login-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
+.btn.apple { background: var(--text); border-color: var(--text); color: var(--bg); }
+.notice { border-color: var(--warn); color: var(--text); }
+dl.account { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
+dl.account dt { color: var(--muted); }
+dl.account dd { margin: 0; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ok { color: var(--ok); }
diff --git a/src/routes.js b/src/routes.js
index 0465867..87b4da5 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -2,8 +2,8 @@ import { now, getSetting, setSetting } from './db.js';
import { encrypt, encryptJson, decryptJson, verifyUnsubToken } from './crypto.js';
import { html, json, redirect, readBody, HttpError } from './http.js';
import { startLogin, finishLogin, destroySession } from './auth.js';
-import { canRunAi, assertCanRunAi, AI_BLOCKED_MESSAGE } from './users.js';
-import { loginPage, dashboardPage, settingsPage, unsubPage } from './views.js';
+import { canRunAi, assertCanRunAi, AI_BLOCKED_MESSAGE, deleteUser, normalizeEmail } from './users.js';
+import { loginPage, dashboardPage, settingsPage, unsubPage, accountPage } from './views.js';
import { enqueue, latestJobs, cancelJob, usageSummary } from './services/jobs.js';
import { validateGitUrl, removeRepo } from './services/git.js';
import { fetchRecap, clearRecapCache, validateSelect } from './services/recap.js';
@@ -145,6 +145,23 @@ export function registerRoutes(router, app) {
redirect(res, '/settings?ok');
});
+ // ---------- Mon compte ----------
+ router.get('/account', async ({ res, session, url }) => {
+ html(res, accountPage({ user: session.user, error: url.searchParams.get('e') }));
+ });
+
+ // Suppression du compte : confirmée en saisissant son email ; efface TOUTES les données de l'utilisateur
+ router.post('/account/delete', async ({ req, res, session }) => {
+ const b = await readBody(req);
+ if (normalizeEmail(b.confirm) !== normalizeEmail(session.user.email)) {
+ return redirect(res, `/account?e=${encodeURIComponent("L'email saisi ne correspond pas à celui du compte")}`);
+ }
+ app.worker?.abortUser(session.userId); // un job en cours pour ce compte s'arrête avant l'effacement
+ await deleteUser(app, session.userId);
+ await destroySession(db, req, res);
+ redirect(res, '/login?bye=1');
+ });
+
// ---------- API JSON ----------
router.post('/api/report/send', async ({ res, session }) => {
const r = await sendWeeklyReport(app, session.userId);
diff --git a/src/server.js b/src/server.js
index 117581b..eb4e3ae 100644
--- a/src/server.js
+++ b/src/server.js
@@ -96,6 +96,7 @@ export async function createApp(cfg, { db, worker = true, createTransport } = {}
}),
});
await w.start();
+ app.worker = w;
scheduler = new Scheduler(app);
scheduler.start();
}
diff --git a/src/services/jobs.js b/src/services/jobs.js
index e2a5bce..05dac74 100644
--- a/src/services/jobs.js
+++ b/src/services/jobs.js
@@ -95,6 +95,7 @@ export class Worker {
this.pollMs = pollMs;
this.log = log;
this.current = null;
+ this.currentJob = null;
this.stopped = false;
this.pending = new Set(); // callbacks de notification en vol (attendus à l'arrêt)
this.loopDone = null;
@@ -116,6 +117,11 @@ export class Worker {
await this.idle();
}
+ /** Interrompt le job en cours s'il appartient à cet utilisateur (suppression du compte). */
+ abortUser(userId) {
+ if (this.currentJob && Number(this.currentJob.user_id) === Number(userId)) this.current?.abort();
+ }
+
/** Attend les callbacks (notifications) lancés par emit(). */
async idle() {
while (this.pending.size) await Promise.allSettled([...this.pending]);
@@ -203,6 +209,7 @@ export class Worker {
await this.db.prepare("UPDATE jobs SET status='running', started_at=? WHERE id=? AND status='queued'").run(now(), job.id);
const ctrl = new AbortController();
this.current = ctrl;
+ this.currentJob = job;
const ctx = {
job,
params: JSON.parse(job.params_json || '{}'),
@@ -233,6 +240,7 @@ export class Worker {
} finally {
clearInterval(watch);
this.current = null;
+ this.currentJob = null;
}
return true;
}
diff --git a/src/views.js b/src/views.js
index e5261bf..9d5839f 100644
--- a/src/views.js
+++ b/src/views.js
@@ -48,7 +48,7 @@ ${email ? `` : ''}
${body}
@@ -56,14 +56,42 @@ ${email ? `