Files
clinch/app/helpers/application_helper.rb
Dan Milne bdb10d86fb
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / scan_container (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
CI / system-test (push) Waiting to run
Show OIDC env vars on application show page under a toggle
Previously the copy-pasteable env-var block only appeared right after
creating an app or regenerating credentials. Operators had no easy way
back to it, so they had to reconstruct OIDC_DISCOVERY_URL etc. from
memory.

Adds a collapsed <details> disclosure inside the OIDC Configuration
card with the same env vars (placeholder for the secret, which can't
be re-shown). Extracts the env-line construction into an
oidc_env_lines helper so the flash panel and the persistent display
share one source of truth.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 21:19:14 +10:00

48 lines
1.3 KiB
Ruby

module ApplicationHelper
def smtp_configured?
return true if Rails.env.test?
smtp_address = ENV["SMTP_ADDRESS"]
smtp_port = ENV["SMTP_PORT"]
smtp_address.present? &&
smtp_port.present? &&
smtp_address != "localhost" &&
!smtp_address.start_with?("127.0.0.1") &&
!smtp_address.start_with?("localhost")
end
def email_delivery_method
if Rails.env.development?
ActionMailer::Base.delivery_method
else
:smtp
end
end
def oidc_env_lines(application, client_secret: nil)
lines = ["OIDC_CLIENT_ID=#{application.client_id}"]
lines << if client_secret
"OIDC_CLIENT_SECRET=#{client_secret}"
elsif application.public_client?
"OIDC_CLIENT_SECRET="
else
"OIDC_CLIENT_SECRET=<your-client-secret>"
end
lines << "OIDC_DISCOVERY_URL=#{OidcJwtService.issuer_url}"
lines << "OIDC_PROVIDER_NAME='Clinch'"
lines << "OIDC_REQUIRE_PKCE=#{application.requires_pkce? ? 'true' : 'false'}"
lines
end
def border_class_for(type)
case type.to_s
when "notice" then "border-green-200 dark:border-green-700"
when "alert", "error" then "border-red-200 dark:border-red-700"
when "warning" then "border-yellow-200 dark:border-yellow-700"
when "info" then "border-blue-200 dark:border-blue-700"
else "border-gray-200 dark:border-gray-700"
end
end
end