[Web] Get all app passwd ids for a single user by using get/app-passwd/all/user@domain

master
andryyy 2019-12-21 16:57:58 +01:00
parent b822818cee
commit 0b224d1e07
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
2 changed files with 15 additions and 4 deletions

View File

@ -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;

View File

@ -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;
}