问题描述
|
我正在尝试使OAuth和Devise一起工作,但是在尝试通过Facebook进行身份验证时却得到了“ 0”。
奇怪的是,Google Apps不会发生此问题。 (相同的回调路由)。
有任何想法吗?
callback_controller:
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
# You need to implement the method below in your model
@user = User.find_for_facebook_oauth(env[\"omniauth.auth\"],current_user)
if @user.persisted?
flash[:notice] = I18n.t \"devise.omniauth_callbacks.success\",:kind => \"Facebook\"
sign_in_and_redirect @user,:event => :authentication
else
session[\"devise.facebook_data\"] = env[\"omniauth.auth\"]
redirect_to new_user_registration_url
end
end
def google_apps
@user = User.find_for_google_apps_oauth(env[\"omniauth.auth\"],:kind => \"Google Apps\"
sign_in_and_redirect @user,:event => :authentication
else
session[\"devise.google_apps_data\"] = env[\"omniauth.auth\"]
redirect_to new_user_registration_url
end
end
def passthru
render :file => \"#{Rails.root}/public/404.html\",:status => 404,:layout => false
end
end
route.rb:
devise_for :users,:controllers => { :omniauth_callbacks => \"users/omniauth_callbacks\" } do
get \'/users/auth/:provider\' => \'users/omniauth_callbacks#passthru\'
end
为什么“ 3”会触发RoutingError,而不会触发“ 4”?
解决方法
找到了:
在devise用户模型中,我有以下模块:
:omniauth_providers => [:facebook,:openid,:google_apps]
添加了(显然)没有执行我认为的操作。我删除了这一行,现在我所有的身份验证逻辑再次正常工作。