]> git.mxchange.org Git - friendica.git/commitdiff
Fix: We have to be able to remove delegations as well
authorMichael <heluecht@pirati.ca>
Mon, 12 Mar 2018 04:50:07 +0000 (04:50 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 12 Mar 2018 04:50:07 +0000 (04:50 +0000)
mod/delegate.php

index eeadb8fee0aaad6a70f2d61ee89e744b169b1888..510fc0ec8ff11b7730b53de657f5bda941f81832 100644 (file)
@@ -31,16 +31,18 @@ function delegate_post(App $a)
        $parent_uid = defaults($_POST, 'parent_user', 0);
        $parent_password = defaults($_POST, 'parent_password', '');
 
-       $user = dba::selectFirst('user', ['nickname'], ['uid' => $parent_uid]);
-       if (!DBM::is_result($user)) {
-               notice(L10n::t('Parent user not found.') . EOL);
-               return;
-       }
+       if ($parent_uid != 0) {
+               $user = dba::selectFirst('user', ['nickname'], ['uid' => $parent_uid]);
+               if (!DBM::is_result($user)) {
+                       notice(L10n::t('Parent user not found.') . EOL);
+                       return;
+               }
 
-       $success = User::authenticate($user['nickname'], trim($parent_password));
-       if (!$success) {
-               notice(L10n::t('Permission denied.') . EOL);
-               return;
+               $success = User::authenticate($user['nickname'], trim($parent_password));
+               if (!$success) {
+                       notice(L10n::t('Permission denied.') . EOL);
+                       return;
+               }
        }
 
        dba::update('user', ['parent-uid' => $parent_uid], ['uid' => local_user()]);