mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Add OpenAI token configuration to self-hosting settings (#122)
* feat: add OpenAI settings partial
This commit is contained in:
@@ -3,7 +3,7 @@ class Settings::HostingsController < ApplicationController
|
||||
|
||||
guard_feature unless: -> { self_hosted? }
|
||||
|
||||
before_action :ensure_admin, only: :clear_cache
|
||||
before_action :ensure_admin, only: [ :update, :clear_cache ]
|
||||
|
||||
def show
|
||||
@breadcrumbs = [
|
||||
@@ -31,6 +31,17 @@ class Settings::HostingsController < ApplicationController
|
||||
Setting.twelve_data_api_key = hosting_params[:twelve_data_api_key]
|
||||
end
|
||||
|
||||
if hosting_params.key?(:openai_access_token)
|
||||
Setting.openai_access_token = hosting_params[:openai_access_token]
|
||||
end
|
||||
if hosting_params.key?(:openai_access_token)
|
||||
token_param = hosting_params[:openai_access_token].to_s.strip
|
||||
# Ignore blanks and redaction placeholders to prevent accidental overwrite
|
||||
unless token_param.blank? || token_param == "********"
|
||||
Setting.openai_access_token = token_param
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to settings_hosting_path, notice: t(".success")
|
||||
rescue ActiveRecord::RecordInvalid => error
|
||||
flash.now[:alert] = t(".failure")
|
||||
@@ -44,7 +55,7 @@ class Settings::HostingsController < ApplicationController
|
||||
|
||||
private
|
||||
def hosting_params
|
||||
params.require(:setting).permit(:require_invite_for_signup, :require_email_confirmation, :brand_fetch_client_id, :twelve_data_api_key)
|
||||
params.require(:setting).permit(:require_invite_for_signup, :require_email_confirmation, :brand_fetch_client_id, :twelve_data_api_key, :openai_access_token)
|
||||
end
|
||||
|
||||
def ensure_admin
|
||||
|
||||
Reference in New Issue
Block a user