2010-07-08 50 views
0

我有一個authlogic和facebook應用程序。我第一次登錄到Facebook上後不久,我的所有網頁的停止響應,並且日誌顯示authlogic rails應用程序中的無限循環

Processing UserSessionsController#new (for [IP ADDRESS] at 2010-07-08 00:32:31) [GET] 
    Parameters: {"action"=>"new", "controller"=>"user_sessions"} 

SystemStackError (stack level too deep): 
    (eval):5:in `connection_handler' 
    authlogic (2.1.5) lib/authlogic/session/callbacks.rb:83:in `validate' 
    authlogic (2.1.5) lib/authlogic/session/validation.rb:64:in `valid?' 
    authlogic (2.1.5) lib/authlogic/session/cookies.rb:110:in `persist_by_cookie' 
    authlogic (2.1.5) lib/authlogic/session/callbacks.rb:90:in `persist' 
    authlogic (2.1.5) lib/authlogic/session/persistence.rb:55:in `persisting?' 
    authlogic (2.1.5) lib/authlogic/session/persistence.rb:39:in `find' 
    authlogic (2.1.5) lib/authlogic/acts_as_authentic/session_maintenance.rb:96:in `get_session_information' 
    authlogic (2.1.5) lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `each' 
    authlogic (2.1.5) lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `get_session_information' 
    authlogic (2.1.5) lib/authlogic/session/callbacks.rb:83:in `validate' 
    authlogic (2.1.5) lib/authlogic/session/validation.rb:64:in `valid?' 
    authlogic (2.1.5) lib/authlogic/session/cookies.rb:110:in `persist_by_cookie' 
    authlogic (2.1.5) lib/authlogic/session/callbacks.rb:90:in `persist' 
    authlogic (2.1.5) lib/authlogic/session/persistence.rb:55:in `persisting?' 
    authlogic (2.1.5) lib/authlogic/session/persistence.rb:39:in `find' 
    authlogic (2.1.5) lib/authlogic/acts_as_authentic/session_maintenance.rb:96:in `get_session_information' 
    authlogic (2.1.5) lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `each' 
    authlogic (2.1.5) lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `get_session_information' 

除了有很多更多的迭代。

這裏是我的routes.rb:

map.connect ':controller/:action/:id' 
    map.connect ':controller/:action/:id.:format' 

    map.resource :account, :controller => "users" 
    map.resources :users 

    map.resource :user_session 
    map.root :controller => "user_sessions", :action => "new" # optional, this just sets the root route 

This post暗示,設置餘輝令牌可能會解決問題,但這並沒有幫助我。這是我的user.rb的代碼。它基本上是來自authlogic w/facebook演示的標準代碼:

class User < ActiveRecord::Base 
    is_gravtastic :email, :filetype => :png, :default => "identicon", :size => 120 

    validates_uniqueness_of :name, :message => "should be unique!" 

    def before_connect(facebook_session) 
     logger.info("HEY FACEBOOK, HOW'S IT GOING? SO LOVELY TO SEE: #{facebook_session.user.name}") 

     # Authlogic isn't as magic as we thought: tell it we need a persistence token, based on advice 
     # in http://github.com/binarylogic/authlogic/issuesearch?state=closed&q=persistence#issue/68 
     self.persistence_token = reset_persistence_token 
    end 

    def before_save 
    if self.name.nil? || self.name.blank? 
     self.name = "user#{Time.now.to_i}" 
    end 
    end 


    acts_as_authentic do |c| 
    c.validate_login_field = false 
    # optional, but if a user registers by openid, he should at least share his email-address with the app 
    c.validate_email_field = false 
    c.validate_password_field = false 
    # fetch email by ax 
    c.openid_required_fields = [:email,"http://axschema.org/contact/email"] 
    #c.openid_required_fields = [:language, "http://axschema.org/pref/language"] 
    end 

    def before_connect(facebook_session) 
    self.name = facebook_session.user.name 
    self.birthday = facebook_session.user.birthday_date 
    self.about = facebook_session.user.about_me 
    self.locale = facebook_session.user.locale 
    #self.website = facebook_session.user.website 
    end 



    private 

    def map_openid_registration(registration) 

    if registration.empty? 
     # no email returned 
     self.email_autoset = false 
    else 
     # email by sreg 
     unless registration["email"].nil? && registration["email"].blank? 
     self.email = registration["email"] 
     self.email_autoset = true 
     else 
     # email by ax 
     unless registration['http://axschema.org/contact/email'].nil? && registration['http://axschema.org/contact/email'].first.blank? 
      self.email = registration['http://axschema.org/contact/email'].first 
      self.email_autoset = true 
     else 
      # registration-hash seems to contain information other than the email-address 
      self.email_autoset = false 
     end 
     end 
    end 

    end 

end 

是的。有什麼建議麼?提前致謝。

+0

因此,當你創建一個新的會話..你在哪裏發送用戶?你重定向到'/'嗎?這將導致你回到UserSessionsController#new,因爲你的map.root條目 – 2010-07-08 01:04:43

+0

看到你的UserSessionsController可能會很有用。 – 2010-07-08 01:11:55

回答

-1

更重要的是,我建議你養成一次一個測試的習慣。這樣,你就會知道哪些變化導致了你的問題。