简体   繁体   中英

How can I redirect to current page after a successful Facebook login

I am implementing a Facebook login in my Rails 3 application. I have gotten it to work but it redirects to the "Site URL" I specified in my Facebook application. I would like it to redirect to the page from which the user has logged in. For instance if they login from http://www.site.com/userprofile then it should stay on that page after login.

For security reasons Facebook will only redirect back to a pre-registered URL, you cannot change it dynamically. You have to receive the callback at this pre-definded URL and then redirect the user where you want afterwards.

Alternately, you can run them through the Facebook login in a popup and at the end have the popup just tell the window.opener to reload and then close itself. Just feed it JavaScript instead in the response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM