react-facebook icon indicating copy to clipboard operation
react-facebook copied to clipboard

Logout

Open vhlongon opened this issue 7 years ago • 14 comments

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!

vhlongon avatar Mar 13 '17 18:03 vhlongon

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.

ghost avatar Mar 16 '17 22:03 ghost

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!

vhlongon avatar Mar 17 '17 06:03 vhlongon

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 avatar Mar 17 '17 06:03 vhlongon

@vhlongon can you create a PR for logout?

seeden avatar Mar 17 '17 18:03 seeden

@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

vhlongon avatar Mar 17 '17 19:03 vhlongon

ok I will take a look.

seeden avatar Mar 20 '17 14:03 seeden

I added logout into the API. I will add new Logout component in next release

seeden avatar Apr 28 '17 16:04 seeden

That's great. Let's us know when the docs are updated

vhlongon avatar May 04 '17 20:05 vhlongon

hi, exist an update about this?. Looks like an interesting feature

Memerto avatar Aug 29 '17 17:08 Memerto

Is there any chance to LogoutButton be added?

pjeziorna avatar Nov 14 '17 12:11 pjeziorna

You can use Initialization component in this moment and I will add new Logout component to the project soon

seeden avatar Oct 09 '18 18:10 seeden

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).

heymartinadams avatar Jul 14 '19 05:07 heymartinadams

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 avatar Dec 28 '19 21:12 MiguelTolosa

@MiguelTolosa following

TonislavTachev avatar Sep 19 '20 12:09 TonislavTachev