]> git.mxchange.org Git - friendica.git/commitdiff
Relocate system user creation
authorMichael <heluecht@pirati.ca>
Wed, 18 Nov 2020 05:33:17 +0000 (05:33 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 18 Nov 2020 05:33:17 +0000 (05:33 +0000)
src/Database/DBStructure.php
src/Model/User.php

index dbe68aca1651a9ddcc063219eefd950349cb4cb7..37f55683a16182bd7554279effc362a62b156361 100644 (file)
@@ -1075,24 +1075,6 @@ class DBStructure
                        }               
                }
 
-/*             if (self::existsTable('user') && DBA::exists('user', ['uid' => 0])) {
-                       $system = User::getSystemAccount();
-                       $user = [
-                               "username" => $system['name'],
-                               "nickname" => $system['nick'],
-                               "register_date" => $system['created'],
-                               "pubkey" => $system['pubkey'],
-                               "prvkey" => $system['prvkey'],
-                               "spubkey" => $system['spubkey'],
-                               "sprvkey" => $system['sprvkey'],
-                               "verified" => true,
-                               "page-flags" => User::PAGE_FLAGS_SOAPBOX,
-                               "account-type" => User::ACCOUNT_TYPE_RELAY,
-                       ];
-       
-                       DBA::update('user', $user, ['uid' => 0]);
-               }
-*/
                if (self::existsTable('permissionset')) {
                        if (!DBA::exists('permissionset', ['id' => 0])) {
                                DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']);       
index 1959e95798681a558d80f28b28a340aed686b713..2b70189505fd6b3c79d21fd46faa355838babf26 100644 (file)
@@ -144,6 +144,26 @@ class User
                $system['sprvkey'] = $system['uprvkey'] = $system['prvkey'];
                $system['spubkey'] = $system['upubkey'] = $system['pubkey'];
                $system['nickname'] = $system['nick'];
+
+               // Ensure that the user contains data
+               $user = DBA::selectFirst('user', ['prvkey'], ['uid' => 0]);
+               if (empty($user['prvkey'])) {
+                       $fields = [
+                               'username' => $system['name'],
+                               'nickname' => $system['nick'],
+                               'register_date' => $system['created'],
+                               'pubkey' => $system['pubkey'],
+                               'prvkey' => $system['prvkey'],
+                               'spubkey' => $system['spubkey'],
+                               'sprvkey' => $system['sprvkey'],
+                               'verified' => true,
+                               'page-flags' => User::PAGE_FLAGS_SOAPBOX,
+                               'account-type' => User::ACCOUNT_TYPE_RELAY,
+                       ];
+
+                       DBA::update('user', $fields, ['uid' => 0]);
+               }
+
                return $system;
        }