ruby on rails - Determining current_user with declarative_authorization and authlogic -


I use authlogic to authenticate users. In my controllers I use the current_user, defined (as documented) as follows:

  def current_user_session returned @current_user_session if defined (@ current_user_session) @current_user_session = UserSession.find end def current_user return @current_user if defined? (@ Current_user) @ surf_user = current_user_session & amp; Amp; Current_user_session.record end  

I also use declarative_authorization to manage current user permissions. All the work is done in the normal runtime scenario, but when I perform a functional test that uses the request statement like "get_with", the current_user in the controller is zero I looked through the declarative_authorization test assistant code and found that in this scenario, The declarative_authorization gem actually stores the current (which in turn comes from Thread.current ["current_user"]) Authorization.current_user. So there is quite a mixup of how a current user is controlled in a different scenario of the year

My question:? Is there a proper way of getting current_user in both the normal order and test scenario

You have a before_filter in application_controller like this Can define.

before_filter {| C | Authorization.start_user = c.current_user}


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -