Skip to content
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

Is there a way to check if a user is authenticated with express example? #109

Open
chopfitzroy opened this issue Nov 5, 2016 · 1 comment

Comments

@chopfitzroy
Copy link

Using the express example in the README I would like to check if the user is logged in at the index and if they are not redirect them to /auth/facebook is there a nice way to handle this?

Cheers.

@ffflabs
Copy link

ffflabs commented Jan 31, 2018

You need to enable the Facebook Login script as shown in https://developers.facebook.com/docs/javascript/examples#login

Then, after initialization, check the user login status. If he isn't logged in, then redirect him:

FB.getLoginStatus(function(response) {
  if (response.status === 'connected') {
    console.log('Logged in.');
  }   else {
    location.href = '/auth/facebook';
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants