static function getLoggedIn() { $native_user = User::getLoggedInNative(); $fb_uid = facebook_client()->get_loggedin_user(); if ($fb_uid) { $user = User::getByFacebookUID($fb_uid); if ($native_user) { // connect their accounts. // this way the facebook account is their sole means of auth // for this session, so a "logout" click will work $native_user->logOut(); $native_user->connectWithFacebookUID($fb_uid); $user = $native_user; } else { if (!$user) { $user = User::createFromFacebookUID($fb_uid); } } } if ($native_user && !$user) { $user = $native_user; } return $user; }
include_once 'lib/core.php'; include_once 'lib/fbconnect.php'; /* * This is called after the Facebook Connect button is pressed on the front page * or anywhere on the site. This is the code that links accounts. */ // Gets any credentials for The Run Around $user = User::getLoggedIn(); if (idx($_POST, 'save')) { // Facebook client library will validate the signature against the secret // key, and produce a user id if it all checks out $fb_uid = facebook_client()->get_loggedin_user(); if ($fb_uid) { // The user is connecting an existing account // with their Facebook account. if ($user && $_POST['link_to_current_user']) { $user->connectWithFacebookUID($fb_uid); } else { if (!$user) { $user = User::createFromFacebookUID($fb_uid); } } } } if ($user) { $user->logIn(); echo 1; } else { echo 0; }