-
-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect URI - How to remove "#_=_" from Facebook Redirect? #12
Comments
Here was my fix using Modernizr (with alternative in comments) ... // Remove the ugly Facebook appended hash
// <https://github.com/jaredhanson/passport-facebook/issues/12>
if (window.location.hash && window.location.hash === "#_=_") {
// If you are not using Modernizr, then the alternative is:
// `if (window.history && history.pushState) {`
if (Modernizr.history) {
window.history.pushState("", document.title, window.location.pathname);
} else {
// Prevent scrolling by storing the page's current scroll offset
var scroll = {
top: document.body.scrollTop,
left: document.body.scrollLeft
};
window.location.hash = "";
// Restore the scroll offset, should be flicker free
document.body.scrollTop = scroll.top;
document.body.scrollLeft = scroll.left;
}
} |
I'll add this to the Readme since this is a common problem due to Facebook's current bug. |
Added note regarding Facebook's bug with window.location.hash for issue #12
Thanks! |
FYI: it's actually better to use |
@arxpoetica thanks, how does this look? /cc @jaredhanson (do we need to update docs?) // Remove the ugly Facebook appended hash
// <https://github.com/jaredhanson/passport-facebook/issues/12>
if (window.location.hash && window.location.hash === "#_=_") {
// If you are not using Modernizr, then the alternative is:
// `if (window.history && history.replaceState) {`
if (Modernizr.history) {
window.history.replaceState("", document.title, window.location.pathname);
} else {
// Prevent scrolling by storing the page's current scroll offset
var scroll = {
top: document.body.scrollTop,
left: document.body.scrollLeft
};
window.location.hash = "";
// Restore the scroll offset, should be flicker free
document.body.scrollTop = scroll.top;
document.body.scrollLeft = scroll.left;
}
} |
Yup. That's what I did in my app. |
@jerone why'd you remove your comment? how about this /cc @arxpoetica // Remove the ugly Facebook appended hash
// <https://github.com/jaredhanson/passport-facebook/issues/12>
(function removeFacebookAppendedHash() {
if (!window.location.hash || window.location.hash !== '#_=_')
return;
if (window.history && window.history.replaceState)
return window.history.replaceState('', document.title, window.location.pathname + window.location.search);
// Prevent scrolling by storing the page's current scroll offset
var scroll = {
top: document.body.scrollTop,
left: document.body.scrollLeft
};
window.location.hash = "";
// Restore the scroll offset, should be flicker free
document.body.scrollTop = scroll.top;
document.body.scrollLeft = scroll.left;
}()); |
Word. |
Because I posted exactly what the comment already noted, which I stupidly saw after posting.
|
I can't believe that facebook hasn't fixed this issue, yet. |
I am not sure if that's a Facebook issue @pedramphp. https://developers.facebook.com/blog/post/552/
|
The fragment is added even when the redirect_uri is not blank (actually, it doesn't work anyway without the redirect_uri parameter, as far as I can see) ... :( And Facebook seems to have removed the bug, so it's great. Could this hash be removed from passport side ? : / |
I've found another Facebook bug about this, which heavily implies that :
I think that node-passport should support this and drop the hash altogether, since its only purpose is to prevent the previous one from being transmitted. |
@arcanis: +1 |
Thanks for the fix, guys! It was driving me crazy |
Where do I place the code? // Remove the ugly Facebook appended hash |
When user try to log in with FB, then I redirect him to my web url "/fb", but this code is clear my "/fb" get param... |
I had this problem and tried a lot of things. How ever when I added website and hit quick start in the app (in website title bar on app site) They said to put it after body and So I did. window.fbAsyncInit = function() { (function(d, s, id){ Everything worked after what .. Since I'm using jwt and not session I had to add in the callback app.get('/auth/facebook/callback', passport.authenticate('facebook', { Now I get the information from Facebook but some variable's undefined, but it is step forward. Hope this works for you too :) |
Епт, на дворе 2016 год, а до сих пор не исправили баг. |
@niftylettuce For completeness, it would be good to add the query string to the url rewrite:
|
done @cadilhac |
Епт, на дворе середина 2017 года, а до сих пор не исправили баг. |
А и не говори. |
ёпт, на дворе начало 2018 года, а до сих пор не исправили баг. |
Баг не баг, а не покую ли как строка выглядет? Пить, есть не просит. Ее преобразовать можно с помощью windows.history или что-то в этом роде. Да мне просто лень это делать, да и не во всех браузерах сиё работает. |
Че интересно так history.replacestate в файерфоксе почему-то не возымеет никакого действия, в ие не пробовал. В хроме отлично работает, на ура. |
2018... still |
@vtrykoz середина 2018-го уже. |
@Globik и не говори |
The answer is: if(location.hash = '#_=_'){
location.href = location.href.split('#')[0];
}; |
На дворе начало 2019, до сих пор не исправили баг! 😱 |
Март 2020, до сих пор не исправили баг! |
Еще пару годиков и багу исполнится десятилетие |
Haha, no it's not. This will put you in an infinite loop. ;) (the single = will set it to '#=', therefore making it always true, instead of comparing it) |
Март 2021, до сих пор не исправили баг! |
Привет из 2023 |
UPDATE: See this comment towards end of this issue comment thread for the latest version of the fix for this issue.
Not sure how to fix this, since there isn't an immediate answer as to how to set the redirect URI.
Found this on SO: http://stackoverflow.com/questions/7693663/remove-from-the-facebook-redirect-url.
Also this will help to provide context: https://developers.facebook.com/bugs/196125357123225.
The text was updated successfully, but these errors were encountered: