Add disconnect from 3rdparty provider option for administrators
authorJoshua Rüsweg <ruesweg@woltlab.com>
Fri, 28 Jun 2019 20:49:22 +0000 (22:49 +0200)
committerJoshua Rüsweg <ruesweg@woltlab.com>
Fri, 28 Jun 2019 20:49:22 +0000 (22:49 +0200)
See #2951

wcfsetup/install/files/acp/templates/userAdd.tpl
wcfsetup/install/files/lib/acp/form/UserEditForm.class.php

index 48e10f0ea997ab752a4b7f1282c5625accfe07e4..7a06ba541effdcbfa115685f0919e91d8d70a506 100644 (file)
                                                <h2 class="sectionTitle">{lang}wcf.user.3rdparty{/lang}</h2>
                                                
                                                <div class="info">{lang}wcf.user.3rdparty.connect.info{/lang}</div>
+                                               
+                                               <dl>
+                                                       <dt></dt>
+                                                       <dd>
+                                                               <label><input type="checkbox" name="disconnect3rdParty" value="1"> {lang}wcf.user.3rdparty.{$user->getAuthProvider()}.disconnect{/lang}</label>
+                                                       </dd>
+                                               </dl>
                                        </section>
                                {else}
                                        <section class="section">
index 9d4e7121f716df0f97c3ae9715be513163b732b3..c86d7407887dea6f0d1b0c0316cb3fa0e839bd14 100755 (executable)
@@ -127,6 +127,12 @@ class UserEditForm extends UserAddForm {
         */
        public $deleteCoverPhoto = 0;
        
+       /**
+        * true to delete the current auth data
+        * @var boolean
+        */
+       public $disconnect3rdParty = 0;
+       
        /**
         * @inheritDoc
         */
@@ -186,6 +192,8 @@ class UserEditForm extends UserAddForm {
                                if (isset($_POST['disableCoverPhotoExpires'])) $this->disableCoverPhotoExpires = @strtotime(StringUtil::trim($_POST['disableCoverPhotoExpires']));
                        }
                }
+               
+               if (WCF::getSession()->getPermission('admin.user.canEditPassword') && isset($_POST['disconnect3rdParty'])) $this->disconnect3rdParty = 1;
        }
        
        /**
@@ -319,6 +327,10 @@ class UserEditForm extends UserAddForm {
                
                $this->additionalFields = array_merge($this->additionalFields, $avatarData);
                
+               if ($this->disconnect3rdParty) {
+                       $this->additionalFields['authData'] = '';
+               }
+               
                // add default groups
                $defaultGroups = UserGroup::getAccessibleGroups([UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS]);
                $oldGroupIDs = $this->user->getGroupIDs();
@@ -410,8 +422,8 @@ class UserEditForm extends UserAddForm {
                // reset password
                $this->password = $this->confirmPassword = '';
                
-               // reload user when deleting the cover photo
-               if ($this->deleteCoverPhoto) $this->user = new User($this->userID);
+               // reload user when deleting the cover photo or disconneting from 3rd party auth provider
+               if ($this->deleteCoverPhoto || $this->disconnect3rdParty) $this->user = new User($this->userID);
                
                // show success message
                WCF::getTPL()->assign('success', true);