OmniAuth 的起源 - /auth/facebook 是从哪里调用的
我使用 OmniAuth 作为让用户将其社交网络链接到系统的一种方式。因此,我的路线中有常见的匹配 '/auth/:provider/callback', to: 'authentications#create'
。
这很好,我将特定用户的信息存储在表中。但是,我有另一种使用 OmniAuth 的方法,该方法不应与此方法重叠。用户可以使用对 /auth/facebook 的调用来登录系统,因此我不仅应该将该信息存储到身份验证表中,还应该将用户登录到系统中。
另一方面,已登录的用户可能只想链接他/她的 Facebook 帐户而不登录,但调用将针对相同的 /auth/facebook
进行。所以我的问题是:我如何才能发现对 auth/facebook 的调用是从哪里完成的?
I'm using OmniAuth as a way to let users link their social networks into a system. So I have the common match '/auth/:provider/callback', to: 'authentications#create'
in my routes.
This is fine, and I store that info for a particular user in a table. However, I have another way of using OmniAuth that should not overlap this one. The users can use a call to /auth/facebook to log into the system and therefore I should not just store that information into the authentications table, but also log the user into the system.
On the other hand, a user that is logged in might just want to link his/her Facebook account without logging in but the call will be done to the same /auth/facebook
. So my question is: How can I discover where that call to auth/facebook
was done from?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个想法是在您的身份验证控制器中添加一个
before_filter
,它只是检查用户是否已经登录。#sign_in?
可能看起来像这样:An idea would be to have a
before_filter
in your authentications controller, which simply checks if the user is already signed-in.#sign_in?
might look something like this: