我将用户发送到 Twitter 以授权我的应用程序使用他们的帐户。
如果用户单击登录并正确验证,则他们将被发送到失败方法。我仍然可以通过返回的哈希访问他们的oauth_token
和。oauth_token_secret
(对我来说似乎很奇怪?)
无论用户单击登录还是取消,它们总是被发送回失败方法。
为什么他们在正确验证时没有被发送到成功方法?
在我的路线文件中,我尝试使用
devise_for :users, :controllers => { :registrations => 'registrations',
:omniauth_callbacks => "authentications" }
但它从不调用 create 方法,总是调用 failure 方法。
我究竟做错了什么?
编辑: authentications_controller.rb
class AuthenticationsController < Devise::OmniauthCallbacksController
def create
render :text => 'yes'
end
def failure
render :text => request.env['omniauth.auth']
end
alias_method :twitter, :create
end
路线.rb
MyApp::Application.routes.draw do
resources :authentications
devise_for :users, :controllers => { :registrations => 'registrations',
:omniauth_callbacks => "authentications" }
resources :users
end