Devise + Omniauth - 如何传递额外的参数? [英] Devise + Omniauth - How to pass extra parameters along?

查看:36
本文介绍了Devise + Omniauth - 如何传递额外的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在应用程序中加载/users/auth/facebook 以连接到 facebook.我希望能够知道请求来自哪里.无论是来自注册 facebook 的用户,还是只想与 facebook 联系的现有用户.根据类型,反应非常不同.

I have the ability in the app to load /users/auth/facebook to connect to facebook. I want to be able to know where the request came from. Whether it was from a user who is registering with facebook, or a existing user who simply wants to connect with facebook. Based on the type, the responses are very different.

如何在认证时将参数传递给 omniauth.我试着做:

How can I pass a param along to omniauth when authenticating. I tried doing:

/users/auth/facebook?connect_action=signup_connect_to_facebook

但是当它点击 AuthenticationsController#Create 时,connect_action 参数没有成功

But that connect_action param didn't make it when it hit AuthenticationsController#Create

想法?谢谢

推荐答案

你必须使用 :params 选项,如

You have to use the :params options, as in

omniauth_authorize_path(:user, :facebook, var: 'value', var2: 'value2' )

稍后在回调中,您可以访问 request.env['omniauth.params'] 以获取哈希值!:)

and later in the callback you can access request.env['omniauth.params'] to get the hash! :)

这篇关于Devise + Omniauth - 如何传递额外的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆