Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook omniauth callback and #_

I use Rails 3.1, Devise and Omniauth.

The problem is that when facebook callbacks to my app the url ends with #_. Then when in the callback action I redirect to something - for example /after_signin the redirect results in /after_signin#_.

Any idea how to remove this anchor from the URL?

EDIT: It does not matter what I put in the callback function. Even simple redirect:

class Users::OmniauthCallbacksController < ApplicationController
  def facebook
    redirect_to "/after_callback"
  end
end

it would result in going to /after_callback#_

Even in normal controller if you go to /#_ and you have some redirect ther it would get redirected to the specified path with #_ appended at the end.

EDIT2: I just found out that it is the browser fault to preserve the anchor. So it has to be handled in the frontend side.

like image 273
Piotr Jakubowski Avatar asked Aug 24 '11 10:08

Piotr Jakubowski


1 Answers

If you're confident that it's a browser issue, you can just use JavaScript to update the hash portion of the window's location object. Maybe something like this:

if (window.location.hash.search('#_') >= 0) {
    window.location.hash = '';
}
like image 69
Chris Schmitz Avatar answered Sep 23 '22 19:09

Chris Schmitz