Bug #1270

remember_token missing

Added by Stephan Dale 67 days ago. Updated 21 days ago.

Status :Closed Start :09/25/2008
Priority :Normal Due date :
Assigned to :neuro - % Done :

0%

Category :backend
Target version :5.2
Resolution :

fixed


Description

With typo 5.1.3, the login system tries to get the current user from the session, then basic authentication and finally the cookie. If it reaches the login_from_cookie method I get the following error:

undefined method `find_by_remember_token'

This error does not occur if I already have a session or if there is no auth_token cookie, only if an old auth_token cookie is present and I'm not logged in. Clearing the cookie removes the problem because the login_from_cookie method returns false immediately and never reaches User.find_by_remember_token.

Log message:

NoMethodError (undefined method `find_by_remember_token' for #<Class:0xb6c227a0>):
    /vendor/rails/activerecord/lib/active_record/base.rb:1483:in `method_missing'
    /vendor/plugins/typo_login_system/lib/login_system.rb:74:in `login_from_cookie'
    /vendor/plugins/typo_login_system/lib/login_system.rb:9:in `current_user'
    /vendor/plugins/typo_login_system/lib/login_system.rb:5:in `logged_in?'
    /vendor/plugins/typo_login_system/lib/login_system.rb:23:in `authorized?'
    /vendor/plugins/typo_login_system/lib/login_system.rb:27:in `login_required'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:469:in `send!'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:469:in `call'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:441:in `run'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:716:in `run_before_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:695:in `call_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /vendor/rails/actionpack/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'
    /vendor/rails/actionpack/lib/action_controller/caching.rb:678:in `perform_action'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
    /vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
    /vendor/rails/actionpack/lib/action_controller/caching.rb:677:in `perform_action'
    /vendor/rails/actionpack/lib/action_controller/base.rb:524:in `send'
    /vendor/rails/actionpack/lib/action_controller/base.rb:524:in `process_without_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:685:in `process_without_session_management_support'
    /vendor/rails/actionpack/lib/action_controller/session_management.rb:123:in `process'
    /vendor/rails/actionpack/lib/action_controller/base.rb:388:in `process'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:171:in `handle_request'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:115:in `dispatch'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:9:in `dispatch'
    /[cut]/dispatch.cgi:10

I have Rails 2.0.2 frozen in vendor.

I'm not sure whether anything fancy is going on that adds the remember_token attribute to the user model, but the user table does not have a remember_token field. Creating a migration that adds the field fixes the problem (though I'm not sure how this fits into the grand scheme of things):

class AddRememberToken < ActiveRecord::Migration
  def self.up
    add_column :users, :remember_token, :string
  end

  def self.down
    remove_column :users, :remember_token
  end
end

History

11/10/2008 07:28 AM - neuro -

  • Category set to backend
  • Status changed from New to Closed
  • Assigned to set to neuro -
  • Target version changed from 5.1.4 to 5.2
  • Resolution set to fixed

I've added the missing column in trunk.
Thank you

Also available in: Atom PDF