Merge pull request #927 from cole-h/nonexistent-user-400

Return HTTP 400 when creating Project with nonexistent user
This commit is contained in:
Graham Christensen 2021-04-26 14:40:15 -04:00 committed by GitHub
commit 453b8479be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

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

@ -136,7 +136,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) = @_;