1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-04 13:05:19 +02:00

Handle invalid API key (#1515)
Some checks failed
Publish Docker image / ci (push) Has been cancelled
Publish Docker image / Build docker image (push) Has been cancelled

* Handle invalid API key

* Show error on invalid API key
This commit is contained in:
Nikhil Badyal 2024-12-04 00:36:59 +05:30 committed by GitHub
parent 565103caf3
commit 13bec4599f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View file

@ -159,7 +159,11 @@ class Family < ApplicationRecord
end end
def synth_overage? 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 end
def subscribed? def subscribed?

View file

@ -1,8 +1,14 @@
<div class="space-y-4"> <div class="space-y-4">
<% if self_hosted? && Current.family&.synth_overage? %> <% if self_hosted? %>
<div class="bg-yellow-100 border border-yellow-400 text-yellow-700 px-4 py-3 rounded relative" role="alert"> <% if Current.family&.synth_overage? %>
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 class="bg-yellow-100 border border-yellow-400 text-yellow-700 px-4 py-3 rounded relative" role="alert">
</div> 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 %> <% end %>
<header class="flex items-center justify-between"> <header class="flex items-center justify-between">
<div> <div>