I have a rails app with authlogic and facebook. Shortly after the first time I logged into facebook, all of my pages stopped responding and logs show
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'
except with a lot more iterations.
Here's my 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 hints that setting the persistence token might fix the problem, but that didn't help me. Here's my code for user.rb. It's basically the standard code from the authlogic w/ facebook demo:
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
Yeah. Any suggestions? Thanks in advance.