From a9feb7982563fa0101f716e9d938ce677fac4fde Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Sat, 18 Dec 2021 04:24:27 +0000 Subject: [PATCH] [SECURITY] New actors are Person user on register by default --- src/Controller/Security.php | 8 +++++++- src/Entity/Actor.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Controller/Security.php b/src/Controller/Security.php index a4426e7d8b..fc94efbc45 100644 --- a/src/Controller/Security.php +++ b/src/Controller/Security.php @@ -10,6 +10,7 @@ use App\Core\Event; use App\Core\Form; use function App\Core\I18n\_m; use App\Core\Log; +use App\Core\UserRoles; use App\Entity\Actor; use App\Entity\Feed; use App\Entity\LocalUser; @@ -146,7 +147,12 @@ class Security extends Controller try { // This already checks if the nickname is being used - $actor = Actor::create(['nickname' => $nickname, 'is_local' => true]); + $actor = Actor::create([ + 'nickname' => $nickname, + 'is_local' => true, + 'type' => Actor::PERSON, + 'roles' => UserRoles::USER, + ]); $user = LocalUser::create([ 'nickname' => $nickname, 'outgoing_email' => $data['email'], diff --git a/src/Entity/Actor.php b/src/Entity/Actor.php index 3a36b83478..70a4e1d956 100644 --- a/src/Entity/Actor.php +++ b/src/Entity/Actor.php @@ -536,7 +536,7 @@ class Actor extends Entity 'id' => ['type' => 'serial', 'not null' => true, 'description' => 'unique identifier'], 'nickname' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username'], 'fullname' => ['type' => 'text', 'description' => 'display name'], - 'roles' => ['type' => 'int', 'not null' => true, 'default' => UserRoles::USER, 'description' => 'Bitmap of permissions this actor has'], + 'roles' => ['type' => 'int', 'not null' => true, 'description' => 'Bitmap of permissions this actor has'], 'type' => ['type' => 'int', 'not null' => true, 'description' => 'The type of actor (person, group, bot, etc)'], 'homepage' => ['type' => 'text', 'description' => 'identifying URL'], 'bio' => ['type' => 'text', 'description' => 'descriptive biography'],