summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application_controller.rb12
-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
5 files changed, 14 insertions, 14 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e4165f3..2d49890 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,13 @@ class ApplicationController < ActionController::Base
private
- def current_user
- begin
- @current_user ||= User.find(session[:user_id]) if session[:user_id]
- rescue ActiveRecord::RecordNotFound
+ def current_user
+ 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
- @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
#