From: Tim Düsterhus Date: Wed, 23 Dec 2020 13:17:49 +0000 (+0100) Subject: Stop filling in the user's profile on social registration X-Git-Tag: 5.4.0_Alpha_1~474^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fd284d18e863858cccd613c7618802ac1d2ade01;p=GitHub%2FWoltLab%2FWCF.git Stop filling in the user's profile on social registration The behavior of this was very inconsistent across providers, required a custom implementation for each of those and over the years less and less data was provided (most notably Facebook drastically limited the available fields). The benefit of filling in the gender and avatar here and there is almost nil, nothing of real value is lost when removing this and it keeps the code simpler. --- diff --git a/wcfsetup/install/files/lib/action/FacebookAuthAction.class.php b/wcfsetup/install/files/lib/action/FacebookAuthAction.class.php index 38b6da7cde..d86b8c775d 100644 --- a/wcfsetup/install/files/lib/action/FacebookAuthAction.class.php +++ b/wcfsetup/install/files/lib/action/FacebookAuthAction.class.php @@ -83,7 +83,7 @@ class FacebookAuthAction extends AbstractAction { try { // fetch userdata - $request = new HTTPRequest('https://graph.facebook.com/me?access_token='.rawurlencode($data['access_token']).'&fields=about,birthday,email,gender,id,location,name,picture.type(large),website'); + $request = new HTTPRequest('https://graph.facebook.com/me?access_token='.rawurlencode($data['access_token']).'&fields=email,id,name'); $request->execute(); $reply = $request->getReply(); diff --git a/wcfsetup/install/files/lib/form/RegisterForm.class.php b/wcfsetup/install/files/lib/form/RegisterForm.class.php index d6863fb6a5..3414c25ed5 100644 --- a/wcfsetup/install/files/lib/form/RegisterForm.class.php +++ b/wcfsetup/install/files/lib/form/RegisterForm.class.php @@ -5,12 +5,10 @@ use wcf\acp\form\UserAddForm; use wcf\data\blacklist\entry\BlacklistEntry; use wcf\data\object\type\ObjectType; use wcf\data\user\avatar\Gravatar; -use wcf\data\user\avatar\UserAvatarAction; use wcf\data\user\group\UserGroup; use wcf\data\user\User; use wcf\data\user\UserAction; use wcf\data\user\UserEditor; -use wcf\data\user\UserProfile; use wcf\system\captcha\CaptchaHandler; use wcf\system\email\mime\MimePartFacade; use wcf\system\email\mime\RecipientAwareTextMimePart; @@ -332,7 +330,6 @@ class RegisterForm extends UserAddForm { $saveOptions = $this->optionHandler->save(); $registerVia3rdParty = false; - $avatarURL = ''; if ($this->isExternalAuthentication) { switch (WCF::getSession()->getVar('__3rdPartyProvider')) { case 'github': @@ -348,9 +345,6 @@ class RegisterForm extends UserAddForm { if (WCF::getSession()->getVar('__email') && WCF::getSession()->getVar('__email') == $this->email) { $registerVia3rdParty = true; } - - if (isset($githubData['bio']) && User::getUserOptionID('aboutMe') !== null) $saveOptions[User::getUserOptionID('aboutMe')] = $githubData['bio']; - if (isset($githubData['location']) && User::getUserOptionID('location') !== null) $saveOptions[User::getUserOptionID('location')] = $githubData['location']; } break; case 'twitter': @@ -364,14 +358,6 @@ class RegisterForm extends UserAddForm { if (WCF::getSession()->getVar('__email') && WCF::getSession()->getVar('__email') == $this->email) { $registerVia3rdParty = true; } - - if (isset($twitterData['description']) && User::getUserOptionID('aboutMe') !== null) $saveOptions[User::getUserOptionID('aboutMe')] = $twitterData['description']; - if (isset($twitterData['location']) && User::getUserOptionID('location') !== null) $saveOptions[User::getUserOptionID('location')] = $twitterData['location']; - - // avatar - if (isset($twitterData['profile_image_url'])) { - $avatarURL = $twitterData['profile_image_url']; - } } break; case 'facebook': @@ -385,19 +371,6 @@ class RegisterForm extends UserAddForm { if (isset($facebookData['email']) && $facebookData['email'] == $this->email) { $registerVia3rdParty = true; } - - if (isset($facebookData['gender']) && User::getUserOptionID('gender') !== null) $saveOptions[User::getUserOptionID('gender')] = ($facebookData['gender'] == 'male' ? UserProfile::GENDER_MALE : UserProfile::GENDER_FEMALE); - - if (isset($facebookData['birthday']) && User::getUserOptionID('birthday') !== null) { - [$month, $day, $year] = explode('/', $facebookData['birthday']); - $saveOptions[User::getUserOptionID('birthday')] = $year.'-'.$month.'-'.$day; - } - if (isset($facebookData['location']) && User::getUserOptionID('location') !== null) $saveOptions[User::getUserOptionID('location')] = $facebookData['location']['name']; - - // avatar - if (isset($facebookData['picture']) && !$facebookData['picture']['data']['is_silhouette']) { - $avatarURL = $facebookData['picture']['data']['url']; - } } break; case 'google': @@ -411,22 +384,6 @@ class RegisterForm extends UserAddForm { if (isset($googleData['email']) && $googleData['email'] == $this->email) { $registerVia3rdParty = true; } - - if (isset($googleData['gender']) && User::getUserOptionID('gender') !== null) { - switch ($googleData['gender']) { - case 'male': - $saveOptions[User::getUserOptionID('gender')] = UserProfile::GENDER_MALE; - break; - case 'female': - $saveOptions[User::getUserOptionID('gender')] = UserProfile::GENDER_FEMALE; - break; - } - } - - // avatar - if (isset($googleData['picture'])) { - $avatarURL = $googleData['picture']; - } } break; } @@ -485,15 +442,6 @@ class RegisterForm extends UserAddForm { // update session WCF::getSession()->changeUser($user); - // set avatar if provided - if (!empty($avatarURL)) { - $userAvatarAction = new UserAvatarAction([], 'fetchRemoteAvatar', [ - 'url' => $avatarURL, - 'userEditor' => $userEditor - ]); - $userAvatarAction->executeAction(); - } - // activation management if (REGISTER_ACTIVATION_METHOD == User::REGISTER_ACTIVATION_NONE && empty($this->blacklistMatches)) { $this->message = 'wcf.user.register.success';