diff --git a/api_keys.php b/api_keys.php index c60480b1..0af7142c 100644 --- a/api_keys.php +++ b/api_keys.php @@ -27,7 +27,7 @@ $del_stmt = Database::prepare("DELETE FROM `" . TABLE_API_KEYS . "` WHERE id = : $success_message = ""; $id = isset($_GET['id']) ? (int) $_GET['id'] : 0; -// do the delete and then just show a success-message and the certificates list again +// do the delete and then just show a success-message and the apikeys list again if ($action == 'delete') { if ($id > 0) { $chk = (AREA == 'admin' && $userinfo['customers_see_all'] == '1') ? true : false; @@ -65,20 +65,21 @@ if ($action == 'delete') { `apikey` = :key, `secret` = :secret, `adminid` = :aid, `customerid` = :cid, `valid_until` = '-1', `allowed_from` = '' "); // customer generates for himself, admins will see a customer-select-box - if (AREA == 'customer') { - $key = hash('sha256', openssl_random_pseudo_bytes(64 * 64)); - $secret = hash('sha512', openssl_random_pseudo_bytes(64 * 64 * 4)); - Database::pexecute($ins_stmt, array( - 'key' => $key, - 'secret' => $secret, - 'aid' => $userinfo['adminid'], - 'cid' => $userinfo['customerid'] - )); - redirectTo($filename, array( - 'page' => $page, - 's' => $s - )); + if (AREA == 'admin') { + $cid = 0; } + elseif (AREA == 'customer') { + $cid = $userinfo['customerid']; + } + $key = hash('sha256', openssl_random_pseudo_bytes(64 * 64)); + $secret = hash('sha512', openssl_random_pseudo_bytes(64 * 64 * 4)); + Database::pexecute($ins_stmt, array( + 'key' => $key, + 'secret' => $secret, + 'aid' => $userinfo['adminid'], + 'cid' => $cid + )); + $success_message = $lng['apikeys']['apikey_added']; } $log->logAction(USR_ACTION, LOG_NOTICE, "viewed api::api_keys"); @@ -167,8 +168,8 @@ if (count($all_keys) == 0) { $row = htmlentities_array($key); // shorten keys - $row['apikey'] = substr($row['apikey'], 0, 20) . '...'; - $row['secret'] = substr($row['secret'], 0, 20) . '...'; + $row['_apikey'] = substr($row['apikey'], 0, 20) . '...'; + $row['_secret'] = substr($row['secret'], 0, 20) . '...'; // check whether the api key is not valid anymore $isValid = true; diff --git a/lng/english.lng.php b/lng/english.lng.php index eccc3693..a409f5da 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -2135,3 +2135,9 @@ $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'; +$lng['apikeys']['apikey_added'] = 'A new api key has been generated successfully'; +$lng['apikeys']['clicktoview'] = 'Click to view'; +$lng['apikeys']['allowed_from'] = 'Allowed from'; +$lng['apikeys']['allowed_from_help'] = 'Comma separated list of ip addresses. Default empty.'; +$lng['apikeys']['valid_until'] = 'Valid until'; +$lng['apikeys']['valid_until_help'] = 'Date until valid, format YYYY-MM-DD'; diff --git a/lng/german.lng.php b/lng/german.lng.php index 3e98de24..e45d5c0b 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1785,3 +1785,7 @@ $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.'; +$lng['apikeys']['allowed_from'] = 'Erlaube Zugriff von'; +$lng['apikeys']['allowed_from_help'] = 'Komma getrennte Liste von IPs. Standard ist leer.'; +$lng['apikeys']['valid_until'] = 'Gültig bis'; +$lng['apikeys']['valid_until_help'] = 'Datum Gültigkeitsende, Format JJJJ-MM-TT'; diff --git a/templates/Sparkle/api_keys/keys_key.tpl b/templates/Sparkle/api_keys/keys_key.tpl index 12eb43a2..263d0807 100644 --- a/templates/Sparkle/api_keys/keys_key.tpl +++ b/templates/Sparkle/api_keys/keys_key.tpl @@ -3,10 +3,10 @@ {$adminCustomerLink}
| User | -API-keys | +{$lng['login']['username']} | +API-key | Secret | -Allowed from | -Valid until | +{$lng['apikeys']['allowed_from']} | +{$lng['apikeys']['valid_until']} | {$lng['panel']['options']} |
|---|