From 0b224d1e07491aa3de18328281fefda2f7030f24 Mon Sep 17 00:00:00 2001 From: andryyy Date: Sat, 21 Dec 2019 16:57:58 +0100 Subject: [PATCH] [Web] Get all app passwd ids for a single user by using get/app-passwd/all/user@domain --- data/web/inc/functions.app_passwd.inc.php | 2 +- data/web/json_api.php | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/data/web/inc/functions.app_passwd.inc.php b/data/web/inc/functions.app_passwd.inc.php index 5274dacd..f960198c 100644 --- a/data/web/inc/functions.app_passwd.inc.php +++ b/data/web/inc/functions.app_passwd.inc.php @@ -200,7 +200,7 @@ function app_passwd($_action, $_data = null) { FROM `app_passwd` WHERE `id` = :id AND `mailbox` = :username"); - $stmt->execute(array(':id' => $_data, ':username' => $username)); + $stmt->execute(array(':id' => $_data['id'], ':username' => $username)); $app_passwd_data = $stmt->fetch(PDO::FETCH_ASSOC); return $app_passwd_data; break; diff --git a/data/web/json_api.php b/data/web/json_api.php index a59d2f57..a4974488 100644 --- a/data/web/json_api.php +++ b/data/web/json_api.php @@ -288,10 +288,21 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u case "app-passwd": switch ($object) { case "all": - $app_passwds = app_passwd('get'); + if (empty($extra)) { + $app_passwds = app_passwd('get'); + } + else { + $app_passwds = app_passwd('get', array('username' => $extra)); + } if (!empty($app_passwds)) { foreach ($app_passwds as $app_passwd) { - if ($details = app_passwd('details', $app_passwd['id'])) { + if (empty($extra)) { + $details = app_passwd('details', array('id' => $app_passwd['id'])); + } + else { + $details = app_passwd('details', array('id' => $app_passwd['id'], 'username' => $extra)); + } + if ($details !== false) { $data[] = $details; } else { @@ -306,7 +317,7 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u break; default: - $data = app_passwd('details', $object); + $data = app_passwd('details', array('id' => $object)); process_get_return($data); break; }