implement deleting of api-keys via webinterface
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
38
api_keys.php
38
api_keys.php
@@ -23,6 +23,44 @@ if (! defined('AREA')) {
|
||||
// This file is being included in admin_index and customer_index
|
||||
// and therefore does not need to require lib/init.php
|
||||
|
||||
$del_stmt = Database::prepare("DELETE FROM `" . TABLE_API_KEYS . "` WHERE id = :id");
|
||||
$success_message = "";
|
||||
|
||||
// do the delete and then just show a success-message and the certificates list again
|
||||
if ($action == 'delete') {
|
||||
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
|
||||
if ($id > 0) {
|
||||
$chk = (AREA == 'admin' && $userinfo['customers_see_all'] == '1') ? true : false;
|
||||
if (AREA == 'customer') {
|
||||
$chk_stmt = Database::prepare("
|
||||
SELECT c.customerid FROM `" . TABLE_PANEL_CUSTOMERS . "` c
|
||||
LEFT JOIN `" . TABLE_API_KEYS . "` ak ON ak.customerid = c.customerid
|
||||
WHERE ak.`id` = :id AND c.`customerid` = :cid
|
||||
");
|
||||
$chk = Database::pexecute_first($chk_stmt, array(
|
||||
'id' => $id,
|
||||
'cid' => $userinfo['customerid']
|
||||
));
|
||||
} elseif (AREA == 'admin' && $userinfo['customers_see_all'] == '0') {
|
||||
$chk_stmt = Database::prepare("
|
||||
SELECT a.adminid FROM `" . TABLE_PANEL_ADMINS . "` a
|
||||
LEFT JOIN `" . TABLE_API_KEYS . "` ak ON ak.adminid = a.adminid
|
||||
WHERE ak.`id` = :id AND a.`adminid` = :aid
|
||||
");
|
||||
$chk = Database::pexecute_first($chk_stmt, array(
|
||||
'id' => $id,
|
||||
'aid' => $userinfo['adminid']
|
||||
));
|
||||
}
|
||||
if ($chk !== false) {
|
||||
Database::pexecute($del_stmt, array(
|
||||
'id' => $id
|
||||
));
|
||||
$success_message = sprintf($lng['apikeys']['apikey_removed'], $id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed api::api_keys");
|
||||
|
||||
// select all my (accessable) certificates
|
||||
|
||||
@@ -2126,3 +2126,4 @@ $lng['menue']['main']['apihelp'] = 'API help';
|
||||
$lng['menue']['main']['apikeys'] = 'API keys';
|
||||
$lng['apikeys']['no_api_keys'] = 'No API keys found';
|
||||
$lng['apikeys']['key_add'] = 'Add new key';
|
||||
$lng['apikeys']['apikey_removed'] = 'The api key with the id #%s has been removed successfully';
|
||||
|
||||
@@ -1776,3 +1776,4 @@ $lng['menue']['main']['apihelp'] = 'API Hilfe';
|
||||
$lng['menue']['main']['apikeys'] = 'API Keys';
|
||||
$lng['apikeys']['no_api_keys'] = 'Keine API Keys gefunden';
|
||||
$lng['apikeys']['key_add'] = 'API Key hinzufügen';
|
||||
$lng['apikeys']['apikey_removed'] = 'Der API Key mit der ID #%s wurde erfolgreich gelöscht.';
|
||||
|
||||
Reference in New Issue
Block a user