app/controllers/sessions_controller.rb
# Perform tasks for a user who just successfully logged in.
Perform tasks for a user who just successfully logged in.
Perform tasks for a user who just successfully logged in .
def successful_login(user)
    log_in user
    redirect_back_or root_url
    last_login = user.last_login_at
    last_login = t('sessions.no_login_time') if last_login.blank?
    flash[:success] = t('sessions.signed_in', last_login_at: last_login)
    user.update_columns(last_login_at: Time.now.utc)
  end
def successful_login ( user ) log_in user redirect_back_or root_url last_login = user . last_login_at last_login = t ( 'sessions.no_login_time' ) if last_login . blank? flash [ :success ] = t ( 'sessions.signed_in' , last_login_at : last_login ) user . update_columns ( last_login_at : Time . now . utc ) end
Perform tasks for a user who just successfully logged in.
Perform tasks for a user who just successfully logged in .
# Report last login time (this can help users detect problems) # Record last_login_at time.  We use update_columns because # it works even if we don't have the correct email decryption keys, # and so it won't change updated_at (so updated_at becomes more useful). # We don't need the model validations, we're just setting a timestamp. # rubocop: disable Rails/SkipsModelValidations # rubocop: enable Rails/SkipsModelValidations
user
<not_specific>