Currently, my application only allow users to log-in using their google account. Im now in the process of allowing Facebook account to be used for the site.
Since only google account was the authentication method, i used the UserService for checking if a user is logged in:
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
Since I will add Facebook account, what will be the best method to check if a user is login? On either google account or facebook account?
Thanks.
Facebook logins work differently to Google’s and you’ll need to implement Facebook’s OAuth flow: https://developers.facebook.com/docs/authentication/server-side/
When the user returns to your site they will have an
access_token, you can use this to query the Facebook Graph API.