Skip to content

Commit e5f5fc8

Browse files
committed
Add user to project by default
#3377 missed the need to add the user creating the project to the project. Fixes #3406.
1 parent 7cb9a2b commit e5f5fc8

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

app/GraphQL/Mutations/CreateProject.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ class CreateProject
1616
public function __invoke(null $_, array $args): Project
1717
{
1818
Gate::authorize('create', Project::class);
19-
return ProjectService::create($args);
19+
20+
$project = ProjectService::create($args);
21+
22+
$project->users()->attach(auth()->user()?->id, [
23+
'emailtype' => 0,
24+
'emailcategory' => 62,
25+
'emailsuccess' => false,
26+
'emailmissingsites' => false,
27+
'role' => Project::PROJECT_ADMIN,
28+
]);
29+
30+
return $project;
2031
}
2132
}

tests/Feature/GraphQL/Mutations/CreateProjectTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function testCreateProjectUserCreateProject(): void
159159
],
160160
]);
161161

162-
$project->delete();
162+
self::assertContains($this->users['normal']->id, $project->administrators()->pluck('id')->all());
163163
}
164164

165165
public function testCreateProjectAdmin(): void
@@ -196,7 +196,7 @@ public function testCreateProjectAdmin(): void
196196
],
197197
]);
198198

199-
$project->delete();
199+
self::assertContains($this->users['admin']->id, $project->administrators()->pluck('id')->all());
200200
}
201201

202202
/**

0 commit comments

Comments
 (0)