0
0
Fork 0
forked from lix-project/hydra

Return HTTP 400 when creating Project with nonexistent user

This commit is contained in:
Cole Helbling 2021-04-26 11:28:42 -07:00
parent 85e299d3d7
commit 47e19ba22c
No known key found for this signature in database
GPG key ID: B37E0F2371016A4C
3 changed files with 16 additions and 2 deletions
hydra-api.yaml
src/lib/Hydra

View file

@ -170,6 +170,16 @@ paths:
description: when set to true the project is displayed in the web interface
type: boolean
responses:
'400':
description: bad request
content:
application/json:
schema:
type: object
properties:
error:
description: error message
type: string
'403':
description: request unauthorized
content:

View file

@ -135,7 +135,7 @@ sub updateProject {
my $owner = $project->owner;
if ($c->check_user_roles('admin') and defined $c->stash->{params}->{owner}) {
$owner = trim $c->stash->{params}->{owner};
error($c, "The user name $owner does not exist.")
badRequest($c, "The user name $owner does not exist.")
unless defined $c->model('DB::Users')->find($owner);
}

View file

@ -11,7 +11,7 @@ our @ISA = qw(Exporter);
our @EXPORT = qw(
getBuild getPreviousBuild getNextBuild getPreviousSuccessfulBuild
searchBuildsAndEvalsForJobset
error notFound gone accessDenied
error notFound gone accessDenied badRequest
forceLogin requireUser requireProjectOwner requireRestartPrivileges requireAdmin requirePost isAdmin isProjectOwner
requireBumpPrivileges
requireCancelBuildPrivileges
@ -155,6 +155,10 @@ sub accessDenied {
error($c, $msg, 403);
}
sub badRequest {
my ($c, $msg) = @_;
error($c, $msg, 400);
}
sub backToReferer {
my ($c) = @_;