From bf8c670b8fc3d9b13cb3defad23d538a692c2cc6 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 18 Aug 2016 00:37:06 +0200 Subject: [PATCH] Reduced amount of config settings for public interface calls. --- app/controllers/application_controller.rb | 11 +++-- .../20160817000002_update_setting_cti.rb | 14 ++++++ db/seeds.rb | 43 ++++++++++++++++--- 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20160817000002_update_setting_cti.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 22602885d..c441c008b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -380,8 +380,11 @@ class ApplicationController < ActionController::Base # config config = {} - Setting.select('name').where(frontend: true).each { |setting| - config[setting.name] = Setting.get(setting.name) + Setting.select('name, preferences').where(frontend: true).each { |setting| + next if setting.preferences[:authentication] == true && !current_user + value = Setting.get(setting.name) + next if !current_user && (value == false || value.nil?) + config[setting.name] = value } # remember if we can to swich back to user @@ -390,7 +393,9 @@ class ApplicationController < ActionController::Base end # remember session_id for websocket logon - config['session_id'] = session.id + if current_user + config['session_id'] = session.id + end config end diff --git a/db/migrate/20160817000002_update_setting_cti.rb b/db/migrate/20160817000002_update_setting_cti.rb new file mode 100644 index 000000000..b9908b914 --- /dev/null +++ b/db/migrate/20160817000002_update_setting_cti.rb @@ -0,0 +1,14 @@ +class UpdateSettingCti < ActiveRecord::Migration + def up + setting = Setting.find_by(name: 'sipgate_integration') + setting.frontend = true + setting.preferences[:authentication] = true + setting.save! + + %w(system_id ticket_hook customer_ticket_create customer_ticket_create_group_ids customer_ticket_view models_searchable tag_new defaults_calendar_subscriptions_tickets).each { |name| + setting = Setting.find_by(name: name) + setting.preferences[:authentication] = true + setting.save! + } + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 44966d059..2ce3a0120 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -158,7 +158,11 @@ Setting.create_if_not_exists( ], }, state: system_id, - preferences: { online_service_disable: true, placeholder: true }, + preferences: { + online_service_disable: true, + placeholder: true, + authentication: true, + }, frontend: true ) Setting.create_if_not_exists( @@ -1001,7 +1005,11 @@ Setting.create_if_not_exists( }, ], }, - preferences: { render: true, placeholder: true }, + preferences: { + render: true, + placeholder: true, + authentication: true, + }, state: 'Ticket#', frontend: true ) @@ -1173,6 +1181,9 @@ Setting.create_if_not_exists( ], }, state: true, + preferences: { + authentication: true, + }, frontend: true ) @@ -1195,6 +1206,9 @@ Setting.create_if_not_exists( ], }, state: '', + preferences: { + authentication: true, + }, frontend: true ) @@ -1218,6 +1232,9 @@ Setting.create_if_not_exists( ], }, state: true, + preferences: { + authentication: true, + }, frontend: true ) @@ -1498,7 +1515,9 @@ Setting.create_if_not_exists( }, ], }, - preferences: { trigger: ['menu:render', 'chat:rerender'] }, + preferences: { + trigger: ['menu:render', 'chat:rerender'] + }, state: false, frontend: true ) @@ -1518,7 +1537,6 @@ Setting.create_if_not_exists( }, ], }, - preferences: {}, state: '120', frontend: true ) @@ -1530,6 +1548,9 @@ Setting.create_if_not_exists( description: 'Define the models which can be searched for.', options: {}, state: [], + preferences: { + authentication: true, + }, frontend: true, ) @@ -1802,6 +1823,9 @@ Setting.create_if_not_exists( }, ], }, + preferences: { + authentication: true, + }, state: true, frontend: true ) @@ -1826,6 +1850,9 @@ Setting.create_if_not_exists( not_assigned: false, } }, + preferences: { + authentication: true, + }, frontend: true ) @@ -2183,8 +2210,12 @@ Setting.create_if_not_exists( ], }, state: false, - preferences: { prio: 1, trigger: ['menu:render', 'cti:reload'] }, - frontend: false + preferences: { + prio: 1, + trigger: ['menu:render', 'cti:reload'], + authentication: true, + }, + frontend: true ) Setting.create_if_not_exists( title: 'sipgate.io config',