From ec342d3d91d2cfa8c210722354353cfe8a90a8bc Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sat, 12 Jan 2013 11:53:21 +0100 Subject: Add PROVISIONING_KEY_LENGTH as a GsParameter value. #73 --- app/controllers/config_snom_controller.rb | 4 ++-- app/views/phones/_form_core.html.haml | 2 +- app/views/phones/show.html.haml | 2 +- .../20130112103337_set_new_value_for_provisioning_key_length.rb | 9 +++++++++ db/schema.rb | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20130112103337_set_new_value_for_provisioning_key_length.rb diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index cb664db..24f6e59 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -182,9 +182,9 @@ class ConfigSnomController < ApplicationController send_sensitve = @provisioning_authenticated || !@phone.provisioning_key_active @phone_settings = Hash.new() - if defined?(PROVISIONING_KEY_LENGTH) && PROVISIONING_KEY_LENGTH > 0 + if !GsParameter.get('PROVISIONING_KEY_LENGTH').nil? && GsParameter.get('PROVISIONING_KEY_LENGTH') > 0 if @phone.provisioning_key.blank? - @phone.update_attributes({ :provisioning_key => SecureRandom.hex(PROVISIONING_KEY_LENGTH), :provisioning_key_active => false }) + @phone.update_attributes({ :provisioning_key => SecureRandom.hex(GsParameter.get('PROVISIONING_KEY_LENGTH')), :provisioning_key_active => false }) elsif @provisioning_authenticated @phone.update_attributes({ :provisioning_key_active => true }) end diff --git a/app/views/phones/_form_core.html.haml b/app/views/phones/_form_core.html.haml index b09ee35..17b9ca8 100644 --- a/app/views/phones/_form_core.html.haml +++ b/app/views/phones/_form_core.html.haml @@ -11,5 +11,5 @@ - if defined? GsParameter.get('NIGHTLY_REBOOT_OF_PHONES') && GsParameter.get('NIGHTLY_REBOOT_OF_PHONES') == true = f.input :nightly_reboot, :label => t('phones.form.nightly_reboot.label'), :hint => conditional_hint('phones.form.nightly_reboot.hint') - - if defined? PROVISIONING_KEY_LENGTH && PROVISIONING_KEY_LENGTH > 0 + - if !GsParameter.get('PROVISIONING_KEY_LENGTH').nil? && GsParameter.get('PROVISIONING_KEY_LENGTH') > 0 = f.input :provisioning_key_active, :label => t('phones.form.provisioning_key_active.label'), :hint => conditional_hint('phones.form.provisioning_key_active.hint') diff --git a/app/views/phones/show.html.haml b/app/views/phones/show.html.haml index f20facd..0e0dad5 100644 --- a/app/views/phones/show.html.haml +++ b/app/views/phones/show.html.haml @@ -21,7 +21,7 @@ %strong= t('phones.show.nightly_reboot') + ":" = @phone.nightly_reboot -- if defined? PROVISIONING_KEY_LENGTH && PROVISIONING_KEY_LENGTH > 0 +- if !GsParameter.get('PROVISIONING_KEY_LENGTH').nil? && GsParameter.get('PROVISIONING_KEY_LENGTH') > 0 %p %strong= t('phones.show.provisioning_key_active') + ":" = @phone.provisioning_key_active diff --git a/db/migrate/20130112103337_set_new_value_for_provisioning_key_length.rb b/db/migrate/20130112103337_set_new_value_for_provisioning_key_length.rb new file mode 100644 index 0000000..06d0ee8 --- /dev/null +++ b/db/migrate/20130112103337_set_new_value_for_provisioning_key_length.rb @@ -0,0 +1,9 @@ +class SetNewValueForProvisioningKeyLength < ActiveRecord::Migration + def up + GsParameter.create(:entity => nil, :section => 'Provisioning', :name => 'PROVISIONING_KEY_LENGTH', :value => '12', :class_type => 'Integer') + end + + def down + GsParameter.where(:name => 'PROVISIONING_KEY_LENGTH').destroy_all + end +end diff --git a/db/schema.rb b/db/schema.rb index cc5afcc..a6aae9b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130112074800) do +ActiveRecord::Schema.define(:version => 20130112103337) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" -- cgit v1.2.3