J'ai une application rails avec authlogic et facebook. Peu de temps après la première fois que je connecté à Facebook, toutes mes pages a cessé de répondre et les journaux montrentboucle infinie dans l'application rails authlogic
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'
sauf avec beaucoup plus d'itérations.
Voici mon 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 conseils que la mise en jeton de persistance pourrait résoudre le problème, mais cela ne m'a pas aidé. Voici mon code pour user.rb. C'est fondamentalement le code standard de l'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
Ouais. Aucune suggestion? Merci d'avance.
Donc, après avoir créé une nouvelle session .. où envoyez-vous l'utilisateur? Est-ce que vous redirigez vers '/'? Cela va vous conduire à nouveau à UserSessionsController # new à cause de votre entrée map.root –
Voir votre UserSessionsController serait probablement utile. –