mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
* add initial pages for Bank Sync and Lunch Flow * update breadcrumbs on Lunch Flow page * update content for Lunch Flow page * add norefeerrer to Github link * update lunch flow url * nest lunch_flow resource under bank_sync * add a provider link partial * remove trailing whitespaces * update providers style to match merchants page * remove separate lunch flow page * fix hover on dark mode * point lunch flow to custom sure landing page * [i18n] Bank Sync label * [i18n] API Keys * [i18n] Self-Hosting consistency * Security breadcrum, not "securities" default --------- Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
54 lines
1.6 KiB
Ruby
54 lines
1.6 KiB
Ruby
class Settings::HostingsController < ApplicationController
|
|
layout "settings"
|
|
|
|
guard_feature unless: -> { self_hosted? }
|
|
|
|
before_action :ensure_admin, only: :clear_cache
|
|
|
|
def show
|
|
@breadcrumbs = [
|
|
[ "Home", root_path ],
|
|
[ "Self-Hosting", nil ]
|
|
]
|
|
twelve_data_provider = Provider::Registry.get_provider(:twelve_data)
|
|
@twelve_data_usage = twelve_data_provider&.usage
|
|
end
|
|
|
|
def update
|
|
if hosting_params.key?(:require_invite_for_signup)
|
|
Setting.require_invite_for_signup = hosting_params[:require_invite_for_signup]
|
|
end
|
|
|
|
if hosting_params.key?(:require_email_confirmation)
|
|
Setting.require_email_confirmation = hosting_params[:require_email_confirmation]
|
|
end
|
|
|
|
if hosting_params.key?(:brand_fetch_client_id)
|
|
Setting.brand_fetch_client_id = hosting_params[:brand_fetch_client_id]
|
|
end
|
|
|
|
if hosting_params.key?(:twelve_data_api_key)
|
|
Setting.twelve_data_api_key = hosting_params[:twelve_data_api_key]
|
|
end
|
|
|
|
redirect_to settings_hosting_path, notice: t(".success")
|
|
rescue ActiveRecord::RecordInvalid => error
|
|
flash.now[:alert] = t(".failure")
|
|
render :show, status: :unprocessable_entity
|
|
end
|
|
|
|
def clear_cache
|
|
DataCacheClearJob.perform_later(Current.family)
|
|
redirect_to settings_hosting_path, notice: t(".cache_cleared")
|
|
end
|
|
|
|
private
|
|
def hosting_params
|
|
params.require(:setting).permit(:require_invite_for_signup, :require_email_confirmation, :brand_fetch_client_id, :twelve_data_api_key)
|
|
end
|
|
|
|
def ensure_admin
|
|
redirect_to settings_hosting_path, alert: t(".not_authorized") unless Current.user.admin?
|
|
end
|
|
end
|