summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2013-01-29 20:59:22 +0100
committerspag <spag@golwen.net>2013-01-29 20:59:22 +0100
commit880cf1cd12ff8851337bc67f9c29ac53229ac911 (patch)
tree5b685363a9928ceb457fa956cb2880d485276510
parent9928e509175ec6dbb9cd77aaeb06168c0de99d38 (diff)
parent5d84248cf177635a19f033f53abbca87ac5c87bc (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
-rw-r--r--app/controllers/application_controller.rb24
-rw-r--r--app/controllers/call_forwards_controller.rb4
-rw-r--r--app/controllers/gui_functions_controller.rb2
-rw-r--r--app/controllers/softkeys_controller.rb2
-rw-r--r--app/controllers/tenants_controller.rb8
-rw-r--r--app/views/phone_numbers/_form_core.html.haml4
-rw-r--r--app/views/shared/_index_view_edit_destroy_part.html.haml18
-rw-r--r--db/migrate/20130129154700_add_sso_key.rb9
-rw-r--r--db/schema.rb2
-rw-r--r--test/unit/callthrough_test.rb12
10 files changed, 55 insertions, 30 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e4165f3..2aadf19 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -106,7 +106,7 @@ class ApplicationController < ActionController::Base
end
rescue_from CanCan::AccessDenied do |exception|
- if @current_user
+ if current_user
redirect_to root_url, :alert => 'Access denied! Please ask your admin to grant you the necessary rights.'
else
if Tenant.count == 0 && User.count == 0
@@ -121,13 +121,23 @@ class ApplicationController < ActionController::Base
private
- def current_user
- begin
- @current_user ||= User.find(session[:user_id]) if session[:user_id]
- rescue ActiveRecord::RecordNotFound
- session[:user_id] = nil
+ def current_user
+ if session[:user_id] || GsParameter.get('SingleSignOnEnvUserNameKey').blank?
+ if session[:user_id] && User.where(:id => session[:user_id]).any?
+ return User.where(:id => session[:user_id]).first
+ else
+ session[:user_id] = nil
+ return nil
+ end
+ else
+ if User.where(:user_name => request.env[GsParameter.get('SingleSignOnEnvUserNameKey')]).any?
+ auth_user = User.where(:user_name => request.env[GsParameter.get('SingleSignOnEnvUserNameKey')]).first
+ session[:user_id] = auth_user.id
+ return auth_user
+ else
+ return nil
+ end
end
- @current_user
end
def go_to_setup_if_new_installation
diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb
index 001ed60..b1ced87 100644
--- a/app/controllers/call_forwards_controller.rb
+++ b/app/controllers/call_forwards_controller.rb
@@ -28,7 +28,7 @@ class CallForwardsController < ApplicationController
@available_call_forward_cases = []
CallForwardCase.all.each do |available_call_forward_case|
- if GuiFunction.display?("call_forward_case_#{available_call_forward_case.value}_field_in_call_forward_form", @current_user)
+ if GuiFunction.display?("call_forward_case_#{available_call_forward_case.value}_field_in_call_forward_form", current_user)
@available_call_forward_cases << available_call_forward_case
end
end
@@ -112,7 +112,7 @@ class CallForwardsController < ApplicationController
voice_mail_destination,
]
- if GuiFunction.display?('huntgroup_in_destination_field_in_call_forward_form', @current_user)
+ if GuiFunction.display?('huntgroup_in_destination_field_in_call_forward_form', current_user)
HuntGroup.all.each do |hunt_group|
hunt_group_destination = CallForwardingDestination.new()
hunt_group_destination.id = "#{hunt_group.id}:HuntGroup"
diff --git a/app/controllers/gui_functions_controller.rb b/app/controllers/gui_functions_controller.rb
index 0cb7898..4b57322 100644
--- a/app/controllers/gui_functions_controller.rb
+++ b/app/controllers/gui_functions_controller.rb
@@ -58,7 +58,7 @@ class GuiFunctionsController < ApplicationController
private
def load_user_groups
- @user_groups = Tenant.find(@current_user.current_tenant).user_groups.order(:position)
+ @user_groups = Tenant.find(current_user.current_tenant).user_groups.order(:position)
end
def spread_breadcrumbs
diff --git a/app/controllers/softkeys_controller.rb b/app/controllers/softkeys_controller.rb
index d2a2bb9..8f363cd 100644
--- a/app/controllers/softkeys_controller.rb
+++ b/app/controllers/softkeys_controller.rb
@@ -61,7 +61,7 @@ class SoftkeysController < ApplicationController
@softkey_functions = []
SoftkeyFunction.accessible_by(current_ability, :read).each do |softkey_function|
- if GuiFunction.display?("softkey_function_#{softkey_function.name.downcase}_field_in_softkey_form", @current_user)
+ if GuiFunction.display?("softkey_function_#{softkey_function.name.downcase}_field_in_softkey_form", current_user)
@softkey_functions << softkey_function
end
end
diff --git a/app/controllers/tenants_controller.rb b/app/controllers/tenants_controller.rb
index 37874b2..f30246b 100644
--- a/app/controllers/tenants_controller.rb
+++ b/app/controllers/tenants_controller.rb
@@ -27,17 +27,17 @@ class TenantsController < ApplicationController
if @tenant.save
# Become a member of this tenant.
#
- @tenant.tenant_memberships.create(:user_id => @current_user.id)
+ @tenant.tenant_memberships.create(:user_id => current_user.id)
# Groups
#
admin_group = @tenant.user_groups.create(:name => t('gemeinschaft_setups.initial_setup.admin_group_name'))
- admin_group.users << @current_user
+ admin_group.users << current_user
user_group = @tenant.user_groups.create(:name => t('gemeinschaft_setups.initial_setup.user_group_name'))
- user_group.users << @current_user
+ user_group.users << current_user
- @current_user.update_attributes!(:current_tenant_id => @tenant.id)
+ current_user.update_attributes!(:current_tenant_id => @tenant.id)
# Generate the internal_extensions
#
diff --git a/app/views/phone_numbers/_form_core.html.haml b/app/views/phone_numbers/_form_core.html.haml
index a1ce1f3..a0a69db 100644
--- a/app/views/phone_numbers/_form_core.html.haml
+++ b/app/views/phone_numbers/_form_core.html.haml
@@ -4,7 +4,7 @@
= f.input :name, :collection => ['Office', 'Home', 'Mobile', 'Fax'], :include_blank => false, :label => t('phone_numbers.form.name.label'), :hint => conditional_hint('phone_numbers.form.name.hint')
= f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :autofocus => true
- else
- - if @callthrough || @hunt_group_member || @access_authorization || @current_user.current_tenant.array_of_available_internal_extensions_and_dids.count == 0 || @current_user.current_tenant.array_of_available_internal_extensions_and_dids.count > 250
+ - if @callthrough || @hunt_group_member || @access_authorization || current_user.current_tenant.array_of_available_internal_extensions_and_dids.count == 0 || current_user.current_tenant.array_of_available_internal_extensions_and_dids.count > 250
= f.input :number, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :autofocus => true
- else
- = f.input :number, :collection => @current_user.current_tenant.array_of_available_internal_extensions_and_dids, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :include_blank => false, :autofocus => true
+ = f.input :number, :collection => current_user.current_tenant.array_of_available_internal_extensions_and_dids, :label => t('phone_numbers.form.number.label'), :hint => conditional_hint('phone_numbers.form.number.hint'), :include_blank => false, :autofocus => true
diff --git a/app/views/shared/_index_view_edit_destroy_part.html.haml b/app/views/shared/_index_view_edit_destroy_part.html.haml
index 6bb1e7b..d396460 100644
--- a/app/views/shared/_index_view_edit_destroy_part.html.haml
+++ b/app/views/shared/_index_view_edit_destroy_part.html.haml
@@ -4,17 +4,20 @@
- if can? :show, child
%a.btn.btn-small.btn-success{:href => method( :"#{parent.class.name.underscore}_#{child.class.name.underscore}_path" ).(parent, child) }
%i.icon-info-sign.icon-white
- =t("#{child.class.name.underscore.pluralize}.index.actions.show")
+ %span.hidden-phone
+ =t("#{child.class.name.underscore.pluralize}.index.actions.show")
- if can? :edit, child
%a.btn.btn-small.btn-warning{:href => method( :"edit_#{parent.class.name.underscore}_#{child.class.name.underscore}_path" ).(parent, child) }
%i.icon-edit.icon-white
- =t("#{child.class.name.underscore.pluralize}.index.actions.edit")
+ %span.hidden-phone
+ =t("#{child.class.name.underscore.pluralize}.index.actions.edit")
- if can? :destroy, child
%a.btn.btn-small.btn-danger{"data-confirm" => t("#{child.class.name.underscore.pluralize}.index.actions.confirm_destroy"), "data-method" => "delete", :href => method( :"#{parent.class.name.underscore}_#{child.class.name.underscore}_path" ).(parent, child), :rel => "nofollow"}
%i.icon-remove.icon-white
- =t("#{child.class.name.underscore.pluralize}.index.actions.destroy")
+ %span.hidden-phone
+ =t("#{child.class.name.underscore.pluralize}.index.actions.destroy")
- elsif !(defined? child).nil?
%td
@@ -22,15 +25,18 @@
- if can? :show, child
%a.btn.btn-small.btn-success{:href => method( :"#{child.class.name.underscore}_path" ).(child) }
%i.icon-info-sign.icon-white
- =t("#{child.class.name.underscore.pluralize}.index.actions.show")
+ %span.hidden-phone
+ =t("#{child.class.name.underscore.pluralize}.index.actions.show")
- if can? :edit, child
%a.btn.btn-small.btn-warning{:href => method( :"edit_#{child.class.name.underscore}_path" ).(child) }
%i.icon-edit.icon-white
- =t("#{child.class.name.underscore.pluralize}.index.actions.edit")
+ %span.hidden-phone
+ =t("#{child.class.name.underscore.pluralize}.index.actions.edit")
- if can? :destroy, child
%a.btn.btn-small.btn-danger{"data-confirm" => t("#{child.class.name.underscore.pluralize}.index.actions.confirm_destroy"), "data-method" => "delete", :href => method( :"#{child.class.name.underscore}_path" ).(child), :rel => "nofollow"}
%i.icon-trash.icon-white
- =t("#{child.class.name.underscore.pluralize}.index.actions.destroy")
+ %span.hidden-phone
+ =t("#{child.class.name.underscore.pluralize}.index.actions.destroy")
\ No newline at end of file
diff --git a/db/migrate/20130129154700_add_sso_key.rb b/db/migrate/20130129154700_add_sso_key.rb
new file mode 100644
index 0000000..2e47f39
--- /dev/null
+++ b/db/migrate/20130129154700_add_sso_key.rb
@@ -0,0 +1,9 @@
+class AddSsoKey < ActiveRecord::Migration
+ def up
+ GsParameter.create(:name => 'SingleSignOnEnvUserNameKey', :section => 'Generic', :value => '', :class_type => 'Nil', :description => 'When set to a string this env variable will be used to authenticate the user. e.g. REMOTE_USER')
+ end
+
+ def down
+ GsParameter.create(:name => 'SingleSignOnEnvUserNameKey').destroy_all
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 7bae5fd..e1bed77 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 => 20130128121800) do
+ActiveRecord::Schema.define(:version => 20130129154700) do
create_table "access_authorizations", :force => true do |t|
t.string "access_authorizationable_type"
diff --git a/test/unit/callthrough_test.rb b/test/unit/callthrough_test.rb
index 5764c0d..2e8cc56 100644
--- a/test/unit/callthrough_test.rb
+++ b/test/unit/callthrough_test.rb
@@ -12,7 +12,7 @@ class CallthroughTest < ActiveSupport::TestCase
@gemeinschaft_setup.country = Country.first
@gemeinschaft_setup.language = Language.first
- @current_user = @gemeinschaft_setup.build_user(
+ current_user = @gemeinschaft_setup.build_user(
:user_name => I18n.t('gemeinschaft_setups.initial_setup.admin_name'),
:male => true,
:email => 'admin@localhost',
@@ -52,18 +52,18 @@ class CallthroughTest < ActiveSupport::TestCase
@tenant.did_list = '02622-70648-x, 02622-706480'
@tenant.save
- @tenant.tenant_memberships.create(:user_id => @current_user.id)
- @current_user.update_attributes!(:current_tenant_id => @tenant.id)
+ @tenant.tenant_memberships.create(:user_id => current_user.id)
+ current_user.update_attributes!(:current_tenant_id => @tenant.id)
# The first user becomes a member of the 'admin' UserGroup
#
admin_group = @tenant.user_groups.create(:name => I18n.t('gemeinschaft_setups.initial_setup.admin_group_name'))
- admin_group.users << @current_user
+ admin_group.users << current_user
# User group
#
user_group = @tenant.user_groups.create(:name => I18n.t('gemeinschaft_setups.initial_setup.user_group_name'))
- user_group.users << @current_user
+ user_group.users << current_user
# Generate the internal_extensions
#
@@ -84,7 +84,7 @@ class CallthroughTest < ActiveSupport::TestCase
#
assert @gemeinschaft_setup.valid?
assert @sip_domain.valid?
- assert @current_user.valid?
+ assert current_user.valid?
assert @tenant.valid?