diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application_controller.rb | 24 | ||||
-rw-r--r-- | app/controllers/call_forwards_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/gui_functions_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/softkeys_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/tenants_controller.rb | 8 | ||||
-rw-r--r-- | app/views/phone_numbers/_form_core.html.haml | 4 |
6 files changed, 27 insertions, 17 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 |