feat: add GlobalConfigService to support env vars migration (#3288)

This commit is contained in:
Vishnu Narayanan
2021-11-03 23:04:42 +05:30
committed by GitHub
parent 03b1a3d045
commit 97ee1bfa97
7 changed files with 104 additions and 39 deletions

View File

@@ -55,7 +55,7 @@ class Api::V1::AccountsController < Api::BaseController
end
def check_signup_enabled
raise ActionController::RoutingError, 'Not Found' if ENV.fetch('ENABLE_ACCOUNT_SIGNUP', true) == 'false'
raise ActionController::RoutingError, 'Not Found' if GlobalConfig.get_value('ENABLE_ACCOUNT_SIGNUP') == 'false'
end
def pundit_user

View File

@@ -27,7 +27,8 @@ class DashboardController < ActionController::Base
'ANALYTICS_TOKEN',
'ANALYTICS_HOST'
).merge(
APP_VERSION: Chatwoot.config[:version]
APP_VERSION: Chatwoot.config[:version],
ENABLE_ACCOUNT_SIGNUP: GlobalConfigService.load('ENABLE_ACCOUNT_SIGNUP', 'false')
)
end

View File

@@ -34,7 +34,7 @@
window.chatwootConfig = {
hostURL: '<%= ENV.fetch('FRONTEND_URL', '') %>',
fbAppId: '<%= ENV.fetch('FB_APP_ID', nil) %>',
signupEnabled: '<%= ENV.fetch('ENABLE_ACCOUNT_SIGNUP', true) %>',
signupEnabled: '<%= @global_config['ENABLE_ACCOUNT_SIGNUP'] %>',
<% if ENV['VAPID_PUBLIC_KEY'] %>
vapidPublicKey: new Uint8Array(<%= Base64.urlsafe_decode64(ENV['VAPID_PUBLIC_KEY']).bytes %>),
<% end %>