$userData = JSON::decode($content);
// check whether a user is connected to this facebook account
- $user = $this->getUser($userData['id']);
+ $user = User::getUserByAuthData('facebook:'.$userData['id']);
if ($user->userID) {
// a user is already connected, but we are logged in, break
$this->executed();
exit;
}
-
- /**
- * Fetches the User with the given userID.
- *
- * @param integer $userID
- * @return \wcf\data\user\User
- */
- public function getUser($userID) {
- $sql = "SELECT userID
- FROM wcf".WCF_N."_user
- WHERE authData = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array('facebook:'.$userID));
- $row = $statement->fetchArray();
-
- if ($row === false) {
- $row = array('userID' => 0);
- }
-
- $user = new User($row['userID']);
- return $user;
- }
}
}
// check whether a user is connected to this github account
- $user = $this->getUser($userData['id']);
+ $user = User::getUserByAuthData('github:'.$userData['id']);
if (!$user->userID) {
$user = $this->getUser($data['access_token']);
$userEditor = new UserEditor($user);
$this->executed();
exit;
}
-
- /**
- * Fetches the User with the given identifier.
- *
- * @param string $identifier
- * @return \wcf\data\user\User
- */
- public function getUser($identifier) {
- $sql = "SELECT userID
- FROM wcf".WCF_N."_user
- WHERE authData = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array('github:'.$identifier));
- $row = $statement->fetchArray();
-
- if ($row === false) {
- $row = array('userID' => 0);
- }
-
- $user = new User($row['userID']);
- return $user;
- }
}
$userData = JSON::decode($content);
// check whether a user is connected to this google account
- $user = $this->getUser($userData['id']);
+ $user = User::getUserByAuthData('google:'.$userData['id']);
if ($user->userID) {
// a user is already connected, but we are logged in, break
$this->executed();
exit;
}
-
- /**
- * Fetches the User with the given userID.
- *
- * @param integer $userID
- * @return \wcf\data\user\User
- */
- public function getUser($userID) {
- $sql = "SELECT userID
- FROM wcf".WCF_N."_user
- WHERE authData = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array('google:'.$userID));
- $row = $statement->fetchArray();
-
- if ($row === false) {
- $row = array('userID' => 0);
- }
-
- $user = new User($row['userID']);
- return $user;
- }
}
parse_str($content, $data);
// check whether a user is connected to this twitter account
- $user = $this->getUser($data['user_id']);
+ $user = User::getUserByAuthData('twitter:'.$data['user_id']);
if ($user->userID) {
// a user is already connected, but we are logged in, break
return base64_encode(hash_hmac('sha1', $base, $key, true));
}
-
- /**
- * Fetches the User with the given userID
- *
- * @param integer $userID
- * @return \wcf\data\user\User
- */
- public function getUser($userID) {
- $sql = "SELECT userID
- FROM wcf".WCF_N."_user
- WHERE authData = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array('twitter:'.$userID));
- $row = $statement->fetchArray();
-
- if ($row === false) {
- $row = array('userID' => 0);
- }
-
- $user = new User($row['userID']);
- return $user;
- }
}