Fixed basic auth, reset current_user based on basic auth user.

This commit is contained in:
Martin Edenhofer 2012-04-19 14:32:12 +02:00
parent 7f75940c03
commit 4013450a5a

View file

@ -48,8 +48,12 @@ class ApplicationController < ActionController::Base
# a Rails application; logging in sets the session value and # a Rails application; logging in sets the session value and
# logging out removes it. # logging out removes it.
def current_user def current_user
@_current_user ||= session[:user_id] && @_current_user ||= session[:user_id] &&
User.find_by_id( session[:user_id] ) User.find_by_id( session[:user_id] )
end
def current_user_set(user)
@_current_user = user
set_user
end end
def authentication_check def authentication_check
@ -71,7 +75,12 @@ class ApplicationController < ActionController::Base
end end
# return auth ok # return auth ok
return true if message == '' if message == ''
# set basic auth user to current user
current_user_set(userdata)
return true
end
# return auth not ok # return auth not ok
render( render(
@ -103,8 +112,8 @@ class ApplicationController < ActionController::Base
# Sets the current user into a named Thread location so that it can be accessed # Sets the current user into a named Thread location so that it can be accessed
# by models and observers # by models and observers
def set_user def set_user
puts 'set_user' return if !current_user
UserInfo.current_user_id = session[:user_id] UserInfo.current_user_id = current_user.id
end end
def log_view (object) def log_view (object)