function verifyAccountReclamation() { $sr = (int) $this->Facebook()->getUser(); if ($sr == 0) { return true; } $user = FBConnectDB::getUser($sr); return $user; }
function checkCreateAccount() { global $wgUser; $response = new AjaxResponse(); $fb = new FBConnectAPI(); $fb_user = $fb->user(); $error = json_encode(array("status" => "error")); if (empty($fb_user)) { $response->addText($error); return $response; } if ((int) $wgUser->getId() != 0) { $response->addText($error); return $response; } if (FBConnectDB::getUser($fb_user) != null) { $response->addText($error); return $response; } $titleObj = SpecialPage::getTitleFor('Connect'); if (wfReadOnly()) { $response->addText($error); return $response; } if ($wgUser->isBlockedFromCreateAccount()) { $response->addText($error); return $response; } if (count($permErrors = $titleObj->getUserPermissionsErrors('createaccount', $wgUser, true)) > 0) { $response->addText($error); return $response; } $response->addText(json_encode(array("status" => "ok"))); return $response; }
/** * If the user isn't logged in, try to auto-authenticate via Facebook * Connect. The Single Sign On magic of FBConnect happens in this function. */ static function UserLoadFromSession($user, &$result) { global $wgCookiePrefix, $wgTitle, $wgOut, $wgUser; // Check to see if the user can be logged in from Facebook $fb = new FBConnectAPI(); $fbId = $fb->user(); // Check to see if the user can be loaded from the session $localId = isset($_COOKIE["{$wgCookiePrefix}UserID"]) ? intval($_COOKIE["{$wgCookiePrefix}UserID"]) : (isset($_SESSION['wsUserID']) ? $_SESSION['wsUserID'] : 0); // Case: Not logged into Facebook, but logged into the wiki /*if (!$fbId && $localId) { $mwUser = User::newFromId($localId); // If the user was Connected, the JS should have logged them out... // TODO: test to see if they logged in normally (with a password) #if (FBConnectDB::userLoggedInWithPassword($mwUser)) return true; if (count(FBConnectDB::getFacebookIDs($mwUser))) { // Oh well, they shouldn't be here anyways; silently log them out $mwUser->logout(); // Defaults have just been loaded, so save some time $result = false; } } // Case: Logged into Facebook, not logged into the wiki else */ if ($fbId && !$localId) { // Look up the MW ID of the Facebook user $mwUser = FBConnectDB::getUser($fbId); $id = $mwUser ? $mwUser->getId() : 0; // If the user doesn't exist, ask them to name their new account if (!$id && !empty($wgTitle)) { $returnto = $wgTitle->isSpecial('Userlogout') || $wgTitle->isSpecial('Connect') ? '' : 'returnto=' . $wgTitle->getPrefixedURL(); // Don't redirect if we're on certain special pages if ($returnto != '') { // Redirect to Special:Connect so the Facebook user can choose a nickname $wgOut->redirect($wgUser->getSkin()->makeSpecialUrl('Connect', $returnto)); } } else { // TODO: To complete the SSO experience, this should log the user on /* // Load the user from their ID $user->mId = $id; $user->mFrom = 'id'; $user->load(); // Update user's info from Facebook $fbUser = new FBConnectUser($mwUser); $fbUser->updateFromFacebook(); // Authentification okay, no need to continue with User::loadFromSession() $result = true; /**/ } } // Case: Not logged into Facebook or the wiki // Case: Logged into Facebook, logged into the wiki return true; }