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?
An idea would be to have a
before_filterin your authentications controller, which simply checks if the user is already signed-in.#sign_in?might look something like this: