]> git.mxchange.org Git - friendica.git/blobdiff - mod/delegate.php
Just some more fixed notice
[friendica.git] / mod / delegate.php
index eeadb8fee0aaad6a70f2d61ee89e744b169b1888..60cf13046455832bc9038d0064723b5a7f97cf94 100644 (file)
@@ -2,9 +2,11 @@
 /**
  * @file mod/delegate.php
  */
+
 use Friendica\App;
 use Friendica\Core\L10n;
 use Friendica\Core\System;
+use Friendica\Database\dba;
 use Friendica\Database\DBM;
 use Friendica\Model\User;
 
@@ -31,16 +33,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()]);