Stop filling in the user's profile on social registration
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 23 Dec 2020 13:17:49 +0000 (14:17 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 6 Jan 2021 14:43:31 +0000 (15:43 +0100)
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.

wcfsetup/install/files/lib/action/FacebookAuthAction.class.php
wcfsetup/install/files/lib/form/RegisterForm.class.php

index 38b6da7cdeb2c0ef2a3510239dc4782a95eafc50..d86b8c775d23c78e844617162e2d472fe534d06d 100644 (file)
@@ -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();
                                
index d6863fb6a56132801c96860cfc1cf6bf6d837825..3414c25ed576d6c784ba178b18986bcf2c67a621 100644 (file)
@@ -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';