Skip to content

Commit

Permalink
Handle invalid API key (#1515)
Browse files Browse the repository at this point in the history
* Handle invalid API key

* Show error on invalid API key
  • Loading branch information
nikhilbadyal authored Dec 3, 2024
1 parent 565103c commit 13bec45
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/models/family.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ def synth_usage
end

def synth_overage?
self.class.synth_provider && self.class.synth_provider.usage.utilization >= 100
self.class.synth_provider&.usage&.utilization.to_i >= 100
end

def synth_valid?
self.class.synth_provider&.healthy?
end

def subscribed?
Expand Down
14 changes: 10 additions & 4 deletions app/views/pages/dashboard.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<div class="space-y-4">
<% if self_hosted? && Current.family&.synth_overage? %>
<div class="bg-yellow-100 border border-yellow-400 text-yellow-700 px-4 py-3 rounded relative" role="alert">
Your Synth API credit limit has been exceeded. Please visit your <a href="https://dashboard.synthfinance.com/settings" class="font-medium underline hover:text-yellow-900">Synth billing settings</a> to upgrade your plan or wait for your credits to reset.
</div>
<% if self_hosted? %>
<% if Current.family&.synth_overage? %>
<div class="bg-yellow-100 border border-yellow-400 text-yellow-700 px-4 py-3 rounded relative" role="alert">
Your Synth API credit limit has been exceeded. Please visit your <a href="https://dashboard.synthfinance.com/settings" class="font-medium underline hover:text-yellow-900">Synth billing settings</a> to upgrade your plan or wait for your credits to reset.
</div>
<% elsif !Current.family&.synth_valid? %>
<div class="bg-yellow-100 border border-yellow-400 text-yellow-700 px-4 py-3 rounded relative" role="alert">
Your Synth API Key is invalid. Please visit your <a href="https://dashboard.synthfinance.com/dashboard" class="font-medium underline hover:text-yellow-900">Synth dashboard</a> and verify that your API key is correct.
</div>
<% end %>
<% end %>
<header class="flex items-center justify-between">
<div>
Expand Down

0 comments on commit 13bec45

Please sign in to comment.