Skip to content

Commit

Permalink
fix(api): make buffer for api key exp an env var
Browse files Browse the repository at this point in the history
This allows us to make more specific changes for this without deploying,
so we can more quickly align with the dunning process
  • Loading branch information
jefflembeck committed Apr 21, 2023
1 parent 7994417 commit c889753
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions www/runtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1685,8 +1685,11 @@ function ValidateKey(&$test, &$error, $key = null)
}
}
if ($account && is_array($account) && isset($account['accountId']) && isset($account['expiration'])) {
// Check the expiration (with a 2-day buffer)
if (time() <= $account['expiration'] + 172800) {
// Check the expiration (with a buffer)
$seconds_in_day = 86400;
$buffer_days = Util::getSetting('api_key_expiration_buffer_days', 2);
$buffer_seconds = $buffer_days * $seconds_in_day;
if (time() <= $account['expiration'] + $buffer_seconds) {
// Check the balance
$response = $redis->get("C_{$account['accountId']}");
if (isset($response) && $response !== false && is_string($response) && strlen($response) && is_numeric($response)) {
Expand Down

0 comments on commit c889753

Please sign in to comment.