From 087448bb8b3ba4e86d599f27a9af511d5ee60083 Mon Sep 17 00:00:00 2001 From: Jules Date: Tue, 5 May 2026 15:42:59 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20bouton=20=C3=A9dition=20compte=20(nom?= =?UTF-8?q?=20affich=C3=A9,=20webhook,=20mot=20de=20passe)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- web/admin/accounts.php | 99 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 6 deletions(-) diff --git a/web/admin/accounts.php b/web/admin/accounts.php index 2a81fb9..cfc6ff0 100644 --- a/web/admin/accounts.php +++ b/web/admin/accounts.php @@ -71,6 +71,42 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { header('Location: /admin/accounts.php'); exit; } + + if ($_POST['action'] === 'edit') { + $id = (int)$_POST['account_id']; + $display = trim($_POST['display_name'] ?? ''); + $webhook = trim($_POST['webhook_url'] ?? ''); + $newPassword = trim($_POST['new_password'] ?? ''); + + db()->prepare('UPDATE accounts SET display_name = ?, webhook_url = ? WHERE id = ?') + ->execute([$display ?: null, $webhook ?: null, $id]); + + if (strlen($newPassword) >= 6) { + $st = db()->prepare('SELECT username FROM accounts WHERE id = ?'); + $st->execute([$id]); + $row = $st->fetch(); + if ($row) { + $domain = cfg('domain'); + $hash = shell_exec(sprintf('doveadm pw -s SHA512-CRYPT -p %s', escapeshellarg($newPassword))); + $hash = trim($hash ?? ''); + if ($hash) { + shell_exec(sprintf( + "sed -i 's|^%s@%s:.*|%s@%s:%s:::|' /etc/dovecot/users", + $row['username'], $domain, + $row['username'], $domain, $hash + )); + $smbUser = $row['username']; + shell_exec(sprintf('(echo %s; echo %s) | smbpasswd -s %s 2>/dev/null', + escapeshellarg($newPassword), escapeshellarg($newPassword), escapeshellarg($smbUser) + )); + } + } + } + + flash('success', "Compte mis à jour."); + header('Location: /admin/accounts.php'); + exit; + } } $accounts = db()->query( @@ -183,13 +219,19 @@ html_navbar('accounts'); -
- - - -
+
+ + + +
+ @@ -201,4 +243,49 @@ html_navbar('accounts'); + + + +