What makes a good third party software is how extendible it is
When deciding what third party tools to use for a project, one of the key factors that goes into the decision is how much you can customize this tool to fit your own needs. For example, using the Facebook registration plugin might not be a good idea if you want to skin your page in a particular way.
In a previous post we showed how to extend the registration widget to make your own using a token connection instead of the regular connection. But as any web application these days, you might want to add some social aspect to your app using Facebook or Twitter. One way to add social networking to your site is by using “Sign up/in with Facebook”. But if you’re already using Apstrata, this might get tricky since now you are integrating 2 third party tools into your website doing the same functionality. Managing the workflow to handle this needs to be well thought out.
First let’s look at the HTML file that will display the registration widget and the Sign up with Facebook button:
So if the user clicks on the Facebook button and has already connected his Facebook profile to the site, he is logged in to the app. If the user has not connected his Facebook profile but is already registered using the same email, his account is update appropriately and then logged in.
Otherwise, if the user is not yet registered, his info is retrieved from his Facebook profile and a new user is created. Since a password is not provided and it’s required by Apstrata, a random one is generated for the user (although it might never be used by the user himself since they will be using Facebook to sign in to the application in the future).
The logic to determine which scenario we are faced with is handled in the FBLogin.js below:
So there it is… We have an example of how you can integrate social media to your site which uses Apstrata as its backend as a service. I hope that was helpful.