Skip to content

Commit

Permalink
fix: respect payment_required setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Oct 30, 2024
1 parent 136ad69 commit f0cbb9a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}

Expand Down

0 comments on commit f0cbb9a

Please sign in to comment.