Integrate Facebook ...
 
Notifications
Clear all

Integrate Facebook Login with Combu ?

9 Posts
3 Users
0 Reactions
1,083 Views
(@flaengel)
Posts: 15
Eminent Member
Topic starter
 

Sorry, this may be a newbie question ...

But is possible to integrate the FB login with the COMBU ?

 
Posted : 25/06/2014 4:49 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

You can use the official Facebook plugin package (maintained by Facebook team) and integrate it with Combu with small tricks, for example:

  • login with the Facebook plugin and use a string like "FB:" + Facebook User Id as Combu's Username
  • once the user is logged, call the method UserExists on Combu Manager to check if it exists a record for it
  • if the record doesn't exist then you call CreateUser on Combu Manager (for the password you could create one by using the Facebook Id in conjunction with some code to encrypt, of course you should choose an encryption algorithm that will allow you to recalculate to obtain the same string later)
  • if the record exists then you call Login from Combu Manager (look above for the password suggestion)

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 25/06/2014 6:12 pm
(@flaengel)
Posts: 15
Eminent Member
Topic starter
 

Uhm... nice... I'll give a try... tks

 
Posted : 25/06/2014 8:34 pm
(@flaengel)
Posts: 15
Eminent Member
Topic starter
 

Thanks again, I Successfully done it. But I have a couple of questions.

1. How easy is to change the login to EMAIL instead of UserName?

2. I configure the server to have the "REGISTER_EMAIL_ACTIVATION". Is there a way to have this activation bypassed if I automatically created a new user after the Facebook Login ?

3. Is it possible to login without password? Lets say user LogIn with facebook, and he's email is the same as facebook email, that he has previously created the regular creation of user lets say....

 

Thanks.

 
Posted : 26/06/2014 7:21 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

The easiest way to manage the first question is to use the email as Username and a custom data for the display name.

For the second question you need to change at least the create user webservice. An easy way would be to intercept a new parameter in the request at line 113 of users.php to check if it needs to disable the mail send:

$emailRequired = (!isset($_REQUEST["NoMail"]) || $_REQUEST["NoMail"] !== "1");

then add the check for this variable in the statements:

if ($emailRequired && REGISTER_EMAIL_REQUIRED) // current line 113
...
if ($emailRequired && REGISTER_EMAIL_REQUIRED && REGISTER_EMAIL_ACTIVATION) // current line 127

finally add the new parameter "NoMail" with value "1" to the WWWForm in CBManager.CreateUser (or better, duplicate this function with a different name like CreateUserFacebook and add the new parameter in it).

For the third question I won't suggest to allow login without a password, you could use a mix of Facebook Id and your Secret Key to create the password so you will be able to recalculate it correctly every time you need:

string myPassword = YourUserFacebookId + CBManager.instance.secretKey;

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 27/06/2014 8:26 pm
(@flaengel)
Posts: 15
Eminent Member
Topic starter
 

Good, for the second question, done and worked perfect.

 

But I think you didn't understand my 3 question. The scenario is like that for example.

a user "John" register an account, with his email "john@john.com", and his own password, "dog".

 

After that he, decides to click the "Login with facebook", and the facebook log's in.

At that point, I have an facebook login, and will now check the user if it exists... and I see, the email "john@john.com" is already registered, but was not created with the facebook create function, so I cant you my combination of password to login. That's why I think I need to bypass password in this case .... 

 
Posted : 30/06/2014 5:59 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Oh ok I understand now your use case, for this kind of situation I'd create a new webservice action "login_facebook" as well as a new method LoginFacebook in the web class CB_Account and do all the stuff in PHP, I would also add a new field FacebookId in the table (and class) CB_Account to manage it. The LoginFacebook web method would first check if there's a record with the FacebookId passed and automatically create it if not existing. This way you'd completely skip the existing check and create call in the Unity client, because after Facebook login it would automatically create (if needed) and login at once.

Of course this requires some knowledge of PHP and SQL statements, but it's definitely not too hard to code.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 30/06/2014 6:11 pm
(@flaengel)
Posts: 15
Eminent Member
Topic starter
 

Worked Great....

Tks

 
Posted : 07/07/2014 9:23 pm
(@pabloam)
Posts: 14
Eminent Member
 

flaengel said
Worked Great....

Tks  

Hello flanengel, could you share the modification you did ?

It could be fantastic 🙂

 

Kind regards!

 
Posted : 16/06/2017 4:55 pm
Share: