所以,我使用Rails 4,ominiauth和facebook ominiauth但是当我尝试登录时总是重定向到用户/ sign_up设计来创建一个新用户,在我的控制台中显示:
Started GET "/users/auth/facebook/callback?code=AQCGbVuW0AV8d4pfkPWHjSWiM6pLY03rmQwHECQfhZiH2E5wJT8OpeV64SYvCAjsf3nVJrpgeUVFn5CDjUuYoOjbY078fQPwIktgsUh5E7TFYpS3_KLLfhuEEd1ilzT4LHw5SPV78bpHe3-5wLEip2pAkQ0u4M3AUBooNvJyAGLaQqBzyG3NHYTa3DembMOXAgqeZbZubrWLBk6NPoVmUg6-mPp1glmPoUbyZ2S1fE2ynOhbwCqMk-n8sqCmlN9j8SSG6plxZzCUcoWMOEchkYUMBi6TW2UOEamVRSQZcOecxAq8fn0VG7Z_gwDk1VcOTV8&state=58dc14ece55d93513bd89dc06590f0f6cb2d8568c2aac35a" for 127.0.0.1 at 2013-08-08 23:02:50 -0300
I, [2013-08-08T23:02:50.902450 #3121] INFO -- omniauth: (facebook) Callback phase initiated.
Processing by Users::OmniauthCallbacksController#facebook as HTML
Parameters: {"code"=>"AQCGbVuW0AV8d4pfkPWHjSWiM6pLY03rmQwHECQfhZiH2E5wJT8OpeV64SYvCAjsf3nVJrpgeUVFn5CDjUuYoOjbY078fQPwIktgsUh5E7TFYpS3_KLLfhuEEd1ilzT4LHw5SPV78bpHe3-5wLEip2pAkQ0u4M3AUBooNvJyAGLaQqBzyG3NHYTa3DembMOXAgqeZbZubrWLBk6NPoVmUg6-mPp1glmPoUbyZ2S1fE2ynOhbwCqMk-n8sqCmlN9j8SSG6plxZzCUcoWMOEchkYUMBi6TW2UOEamVRSQZcOecxAq8fn0VG7Z_gwDk1VcOTV8", "state"=>"58dc14ece55d93513bd89dc06590f0f6cb2d8568c2aac35a"}
Cart Load (0.3ms) SELECT `carts`.* FROM `carts` WHERE `carts`.`id` = 81 LIMIT 1
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`provider` = 'facebook' AND `users`.`uid` = '100003808270452' ORDER BY `users`.`id` ASC LIMIT 1
(0.2ms) BEGIN
User Exists (0.3ms) SELECT 1 AS one FROM `users` WHERE `users`.`email` = BINARY 'mail@mail.com' LIMIT 1
(0.3ms) ROLLBACK
Redirected to http://0.0.0.0:3000/users/sign_up
我知道失败了,但我不知道因为什么,他搜索并找到了用户,但因为什么不回来成功?
行动是:
def facebook
# You need to implement the method below in your model (e.g. app/models/user.rb)
@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
if @user.persisted?
sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
如果有人可以帮助我对我非常重要,非常感谢。
答案 0 :(得分:0)
您在调用Auth时指定了两个URL。 1)在successfule登录后重定向sumsses params的成功 2)如果发生任何不良事件,则会出错。
使用您的域名创建FB应用程序时必须指定这些内容。
callback_url / callback_path
是变量的名称,您可以通过该调用传递。
参考https://github.com/mkdynamic/omniauth-facebook
希望这有帮助。