engines/adva_user/lib/action_controller/authenticate_user.rb
# Will retrieve the current_user. Will not force a login but
# simply load the current user if a person is logged in. If
# you need the user object loaded with extra options (such as
# eager loading) then create a private method called
# "user_find_options" on your controller that returns a hash
# of the find options you want.
#
# This method will also inform the models of the current user
# if the current user is logged in and the "User" class responds
# to the class method current_user=. This is a nice way to
# communciate the current user down to the model level for
# model-level security. This means you will want to call this
# method at least once before using the model-level security.
# Usually you will call it in a before filter. This method is
# called automatically when authentication_required is applied to
# an action.
Will retrieve the current_user. Will not force a login but
simply load the current user if a person is logged in. If
you need the user object loaded with extra options (such as
eager loading) then create a private method called
"user_find_options" on your controller that returns a hash
of the find options you want.

This method will also inform the models of the current user
if the current user is logged in and the "User" class responds
to the class method current_user=. This is a nice way to
communciate the current user down to the model level for
model-level security. This means you will want to call this
method at least once before using the model-level security.
Usually you will call it in a before filter. This method is
called automatically when authentication_required is applied to
an action.
Will retrieve the current_user . Will not force a login but simply load the current user if a person is logged in . If you need the user object loaded with extra options ( such as eager loading ) then create a private method called " user_find_options " on your controller that returns a hash of the find options you want . This method will also inform the models of the current user if the current user is logged in and the " User " class responds to the class method current_user = . This is a nice way to communciate the current user down to the model level for model - level security . This means you will want to call this method at least once before using the model - level security . Usually you will call it in a before filter . This method is called automatically when authentication_required is applied to an action .
def current_user
        @current_user ||= begin
          try_login
          if session && session[:uid]
            user = find_current_user
            set_user_cookie!(user)
            user
          end
        end
      end
def current_user @current_user ||= begin try_login if session && session [ :uid ] user = find_current_user set_user_cookie! ( user ) user end end end
Will retrieve the current_user.
Will retrieve the current_user .
# Check for session[:uid] here? That would mean that for token auth the # user always needs to be logged out (e.g. in UserController#create). # Looks a bit more robust this way: