Console : nommer ou retirer un admin depuis l'onglet Membres
deploy / deploy (push) Successful in 1m6s

- Boutons « Nommer admin » / « Retirer admin » (motif obligatoire, journal, alerte e-mail).
- Garde-fous côté base (admin.set_admin, migration 20261130170000 appliquée) : double authentification
  active exigée, pas de compte suspendu, jamais sur son propre compte (il reste toujours un admin).
- Fonction Edge « admin » : action set_admin, messages d'erreur explicites.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
Claude committed 2026-11-30 21:24:15 +00:00
1 parent 5e9994091f
commit 9180671d61
5 files changed
+72 -8

No files matched your search

+10 -1
View File
@@ -162,6 +162,14 @@ Deno.serve(async (req) => {
if (r?.ok) alert(body.value ? 'Compte suspendu' : 'Compte réactivé', [`Par ${user.email}.`, `Compte : ${target}`, `Motif : ${reason}`])
return json(200, r)
}
case 'set_admin': {
const target = str(body.user, 36)
if (!UUID.test(target) || typeof body.value !== 'boolean') return json(400, { error: 'paramètres' })
const reason = reasonOf(body.reason)
const [{ r }] = await sql`select admin.set_admin(${user.id}::uuid, ${target}::uuid, ${body.value}::boolean, ${reason}::text) as r`
if (r?.ok) alert(body.value ? 'Nouvel admin' : 'Admin retiré', [`Par ${user.email}.`, `Compte : ${target}`, `Motif : ${reason}`])
return json(200, r)
}
case 'reviews': {
const [{ r }] = await sql`select admin.reviews(${str(body.q, 60)}::text, ${int(body.offset)}::int) as r`
return json(200, r)
@@ -197,7 +205,8 @@ Deno.serve(async (req) => {
} catch (e) {
const msg = (e as Error)?.message ?? 'erreur'
// Messages volontaires (motif manquant, action sur son propre compte) renvoyés tels quels, le reste masqué
if (/motif requis|impossible sur son propre compte/.test(msg)) return json(400, { error: msg.replace(/^.*?(motif requis.*|impossible sur son propre compte).*$/, '$1') })
const known = msg.match(/motif requis \(3 caractères minimum\)|impossible sur son propre compte|double authentification requise|compte suspendu/)
if (known) return json(400, { error: known[0] })
console.error('admin', action, msg)
return json(500, { error: 'erreur serveur' })
}