Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+8 votes
63.4k views
in Q2A Core by
I have build a facebook app (very simple) and would now need that a user can be logged in that way, that at least his ID would be stored as user in the database.

So, inside facebook, he could find his questions again.

As far as i understand, I wouldnt need a password for that user, as he already is logged in into facebook. I have an array with his public data including name and ID and I can get a facebook generated email as well.

Same would be for a user who logges in on the normal website through facebook login.

Once logged in to facebook, the function would just ask if user id allready in database,
if Yes, so log him in without password
if No, store his ID and email in database, log him in.

Second, when he logs out from facebook, I have an event, where I just would need to activate an matching logout function.

Only important thing:

The login function should not replace the normal one, as so because of the missing password, everybody could login that way.

Here is the code I receive from facebook-login: In case he logs in from normal website.


window.fbAsyncInit = function() {
 FB.init({appId: 'xxxxxxxxxxx', status: true, cookie: true, xfbml: true});

     /* All the events registered */
     FB.Event.subscribe('auth.login', function(response) {
         // do something with response
         login();
     });
     FB.Event.subscribe('auth.logout', function(response) {
         // do something with response
         logout();
     });

     FB.getLoginStatus(function(response) {
         if (response.session) {
             // logged in and connected user, someone you know
             login();
         }
     });
 };


May be it is very chaotic, how I am thinking, but as far as I understand, with this two functions for facebook users only, and avoiding a passowrd everything would be done.

However, if it is not possible or too time consuming, please point me in the right direction.

The opportunities with q2a in combination with facebook are fascinating, if someone is interested in further reading I highly recommend the http://thinkdiff.net/ tutorials , the only ones I could find which really have working resuts under the newest facebook changes.

Regards
monk333

1 Answer

–2 votes
by
I am still interested in finding a solution for this, if it would be to complicated I as well could reduce this simple app to an facebook internal use only. So I just would need to know how to access the login and logout function without password usage as users are allready logged in to facebook.

Besides meanwhile I believe that an app, accessible by fb internal AND external users would be a problem regarding the fb TOS as in case of deleting the app by a facebook user all questions and information made by this user would have to be cleande from database.

Thanks again
monk333
...