mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
fix: Handle missing encryption keys gracefully on Poviders config page (#753)
* fix: Handle missing encryption keys gracefully on providers page When Active Record encryption keys are not configured, the settings/providers page would crash with an unhandled exception. This change catches the ActiveRecord::Encryption::Errors::Configuration error and displays a friendly error message instead, explaining that encryption credentials need to be configured before using sync providers. https://claude.ai/code/session_015nPsLWkr12i5ok5bwLtA7p * Simplify rescue block --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,9 @@ class Settings::ProvidersController < ApplicationController
|
||||
]
|
||||
|
||||
prepare_show_context
|
||||
rescue ActiveRecord::Encryption::Errors::Configuration => e
|
||||
Rails.logger.error("Active Record Encryption not configured: #{e.message}")
|
||||
@encryption_error = true
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@@ -1,62 +1,76 @@
|
||||
<%= content_for :page_title, "Sync Providers" %>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<p class="text-secondary mb-4">
|
||||
Configure credentials for third-party sync providers. Settings configured here will override environment variables.
|
||||
</p>
|
||||
</div>
|
||||
<% if @encryption_error %>
|
||||
<div class="p-4 rounded-lg bg-destructive/10 border border-destructive/20">
|
||||
<div class="flex items-start gap-3">
|
||||
<%= icon("triangle-alert", class: "w-5 h-5 text-destructive shrink-0 mt-0.5") %>
|
||||
<div>
|
||||
<h3 class="font-medium text-primary"><%= t("settings.providers.encryption_error.title") %></h3>
|
||||
<p class="text-secondary text-sm mt-1"><%= t("settings.providers.encryption_error.message") %></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div>
|
||||
<p class="text-secondary mb-4">
|
||||
Configure credentials for third-party sync providers. Settings configured here will override environment variables.
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% @provider_configurations.each do |config| %>
|
||||
<%= settings_section title: config.provider_key.titleize, collapsible: true, open: false do %>
|
||||
<%= render "settings/providers/provider_form", configuration: config %>
|
||||
<% unless @encryption_error %>
|
||||
<% @provider_configurations.each do |config| %>
|
||||
<%= settings_section title: config.provider_key.titleize, collapsible: true, open: false do %>
|
||||
<%= render "settings/providers/provider_form", configuration: config %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%# Providers below are hardcoded because they manage Family-scoped connections %>
|
||||
<%# (via their own models like SimplefinItem, LunchflowItem, etc.) rather than global settings. %>
|
||||
<%# They require custom UI for connection management, status display, and sync actions. %>
|
||||
<%# The controller excludes them from @provider_configurations (see prepare_show_context). %>
|
||||
|
||||
<%= settings_section title: "Lunch Flow", collapsible: true, open: false do %>
|
||||
<turbo-frame id="lunchflow-providers-panel">
|
||||
<%= render "settings/providers/lunchflow_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "SimpleFIN", collapsible: true, open: false do %>
|
||||
<turbo-frame id="simplefin-providers-panel">
|
||||
<%= render "settings/providers/simplefin_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "Enable Banking (beta)", collapsible: true, open: false do %>
|
||||
<turbo-frame id="enable_banking-providers-panel">
|
||||
<%= render "settings/providers/enable_banking_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "CoinStats (beta)", collapsible: true, open: false do %>
|
||||
<turbo-frame id="coinstats-providers-panel">
|
||||
<%= render "settings/providers/coinstats_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "Mercury (beta)", collapsible: true, open: false do %>
|
||||
<turbo-frame id="mercury-providers-panel">
|
||||
<%= render "settings/providers/mercury_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "Coinbase (beta)", collapsible: true, open: false do %>
|
||||
<turbo-frame id="coinbase-providers-panel">
|
||||
<%= render "settings/providers/coinbase_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "SnapTrade (beta)", collapsible: true, open: false do %>
|
||||
<turbo-frame id="snaptrade-providers-panel">
|
||||
<%= render "settings/providers/snaptrade_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%# Providers below are hardcoded because they manage Family-scoped connections %>
|
||||
<%# (via their own models like SimplefinItem, LunchflowItem, etc.) rather than global settings. %>
|
||||
<%# They require custom UI for connection management, status display, and sync actions. %>
|
||||
<%# The controller excludes them from @provider_configurations (see prepare_show_context). %>
|
||||
|
||||
<%= settings_section title: "Lunch Flow", collapsible: true, open: false do %>
|
||||
<turbo-frame id="lunchflow-providers-panel">
|
||||
<%= render "settings/providers/lunchflow_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "SimpleFIN", collapsible: true, open: false do %>
|
||||
<turbo-frame id="simplefin-providers-panel">
|
||||
<%= render "settings/providers/simplefin_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "Enable Banking (beta)", collapsible: true, open: false do %>
|
||||
<turbo-frame id="enable_banking-providers-panel">
|
||||
<%= render "settings/providers/enable_banking_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "CoinStats (beta)", collapsible: true, open: false do %>
|
||||
<turbo-frame id="coinstats-providers-panel">
|
||||
<%= render "settings/providers/coinstats_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "Mercury (beta)", collapsible: true, open: false do %>
|
||||
<turbo-frame id="mercury-providers-panel">
|
||||
<%= render "settings/providers/mercury_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "Coinbase (beta)", collapsible: true, open: false do %>
|
||||
<turbo-frame id="coinbase-providers-panel">
|
||||
<%= render "settings/providers/coinbase_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
|
||||
<%= settings_section title: "SnapTrade (beta)", collapsible: true, open: false do %>
|
||||
<turbo-frame id="snaptrade-providers-panel">
|
||||
<%= render "settings/providers/snaptrade_panel" %>
|
||||
</turbo-frame>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -148,6 +148,9 @@ en:
|
||||
providers:
|
||||
show:
|
||||
coinbase_title: Coinbase
|
||||
encryption_error:
|
||||
title: Encryption Configuration Required
|
||||
message: Active Record encryption keys are not configured. Please ensure the encryption credentials (active_record_encryption.primary_key, active_record_encryption.deterministic_key, and active_record_encryption.key_derivation_salt) are properly set up in your Rails credentials or environment variables before using sync providers.
|
||||
coinbase_panel:
|
||||
setup_instructions: "To connect Coinbase:"
|
||||
step1_html: Go to <a href="https://portal.cdp.coinbase.com/projects/api-keys" target="_blank" class="text-primary underline">Coinbase API Settings</a>
|
||||
|
||||
Reference in New Issue
Block a user