Fix project creation by non-admin users

This commit is contained in:
Eelco Dolstra 2020-07-08 12:26:46 +02:00
parent d0deebc4fc
commit b0163e9eae
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -12,12 +12,14 @@ sub projectChain :Chained('/') :PathPart('project') :CaptureArgs(1) {
my ($self, $c, $projectName) = @_;
$c->stash->{params}->{name} //= $projectName;
my $isCreate = $c->action->name eq "project" && $c->request->method eq "PUT";
$c->stash->{project} = $c->model('DB::Projects')->find($projectName);
$c->stash->{isProjectOwner} = isProjectOwner($c, $c->stash->{project});
$c->stash->{isProjectOwner} = !$isCreate && isProjectOwner($c, $c->stash->{project});
notFound($c, "Project $projectName doesn't exist.")
if !$c->stash->{project} && !($c->action->name eq "project" and $c->request->method eq "PUT");
if !$c->stash->{project} && !$isCreate;
}