From f0cbb9a7a745201c3465752390deceda46ac9169 Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Wed, 30 Oct 2024 14:25:00 -0400 Subject: [PATCH] fix: respect payment_required setting --- src/auth.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index 1cbea27a..04e45900 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -88,13 +88,15 @@ impl AuthContext { .get(token) .ok_or_else(|| anyhow::anyhow!("API key not found"))?; - match api_key.query_status { - QueryStatus::Active => (), - QueryStatus::ServiceShutoff => { - bail!("payment required for subsequent requests for this API key"); - } - QueryStatus::MonthlyCapReached => { - bail!("spend limit exceeded for this API key"); + if self.payment_required { + match api_key.query_status { + QueryStatus::Active => (), + QueryStatus::ServiceShutoff => { + bail!("payment required for subsequent requests for this API key"); + } + QueryStatus::MonthlyCapReached => { + bail!("spend limit exceeded for this API key"); + } } }