$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;
}
// List of possible actor names
$possible_accounts = ['friendica', 'actor', 'system', 'internal'];
foreach ($possible_accounts as $name) {
- if (!DBA::exists('user', ['nickname' => $name, 'account_removed' => false, 'expire']) &&
+ if (!DBA::exists('user', ['nickname' => $name, 'account_removed' => false, 'expire' => false]) &&
!DBA::exists('userd', ['username' => $name])) {
DI::config()->set('system', 'actor_name', $name);
return $name;
*/
public static function getById($uid, array $fields = [])
{
- return DBA::selectFirst('user', $fields, ['uid' => $uid]);
+ return !empty($uid) ? DBA::selectFirst('user', $fields, ['uid' => $uid]) : [];
}
/**
* @return array
* @throws HTTPException\NotFoundException
*/
- private static function getAuthenticationInfo($user_info)
+ public static function getAuthenticationInfo($user_info)
{
$user = null;