react-facebook
react-facebook copied to clipboard
Logout
Hi,
I have just started looking into these comps to a new project and they work great, so thanks for that!
But I can't find a way to have a logout button. Could you point me into the right direction? I had a look on the code for FacebookProvider and I thought it would be as quickly as sending a prop to onReady, but that does not seem to work.
Thanks in advance!
You'll need to keep track if the user is logged in and clear that state out when they click on a logout button. You don't send a "logout" request to Facebook, as all they did was give you a token that you can just throw away and ask for another one when a login button is pressed.
Hi, thanks for the reply!
Well, the Facebook SDK has a logout method. But I am not surw how to get hold of the SDK instance from the Facebook Provider component. Is there any change you could put together a simple example of what you describe above? I know that are more people that wonder about that.
Thanks again for you time!
Btw, I see that facebook adds a few cookies when the login request is accepted, so I guess this is what you mean?
Upadting the Redux store is simple enough, but I am not sure how to check the user login status (how to get a hold of the FB SDK instance)
@vhlongon can you create a PR for logout?
@seeden I don't actually anything working. It thought I could get hold on the SDK instance via the Facebook provider component, but I couldn't get it to work. My hope was that you could just update the docs with a simple example
ok I will take a look.
I added logout into the API. I will add new Logout component in next release
That's great. Let's us know when the docs are updated
hi, exist an update about this?. Looks like an interesting feature
Is there any chance to LogoutButton be added?
You can use Initialization component in this moment and I will add new Logout component to the project soon
Perhaps a bit of an anti-pattern, but for now we can use this: window.FB.logout()
.
For this to work you also need to add your website (production site or https://localhost:3000/
as a Platform on your Facebook App (yes, that’s https
— Facebook requires https
even for development).
You can use Initialization component in this moment and I will add new Logout component to the project soon
Can you add some details to the docs on how this works? I still haven't been able to figure out how to log out.
@MiguelTolosa following