diff options
author | spag <spag@golwen.net> | 2013-01-29 20:59:22 +0100 |
---|---|---|
committer | spag <spag@golwen.net> | 2013-01-29 20:59:22 +0100 |
commit | 880cf1cd12ff8851337bc67f9c29ac53229ac911 (patch) | |
tree | 5b685363a9928ceb457fa956cb2880d485276510 /app/controllers/application_controller.rb | |
parent | 9928e509175ec6dbb9cd77aaeb06168c0de99d38 (diff) | |
parent | 5d84248cf177635a19f033f53abbca87ac5c87bc (diff) |
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 24 |
1 files changed, 17 insertions, 7 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 |