From: dkl%redhat.com <> Date: Fri, 25 Jul 2008 02:17:04 +0000 (+0000) Subject: Bug 445885 – User.login should ThrowUserError when called with incorrect parameters X-Git-Tag: bugzilla-3.0.5~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f4af2684355943d01bf2ffe93a1d852fdaf01e1;p=thirdparty%2Fbugzilla.git Bug 445885 – User.login should ThrowUserError when called with incorrect parameters Patch by David Lawrence - r/a=mkanat --- diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm index 7a8057471b..f1a4db7c7a 100755 --- a/Bugzilla/WebService/Constants.pm +++ b/Bugzilla/WebService/Constants.pm @@ -50,6 +50,8 @@ use base qw(Exporter); # comment that it was retired. Also, if an error changes its name, you'll # have to fix it here. use constant WS_ERROR_CODE => { + # Generic Bugzilla::Object errors are 50-99. + param_required => 50, # Bug errors usually occupy the 100-200 range. invalid_bug_id_or_alias => 100, invalid_bug_id_non_existent => 101, diff --git a/Bugzilla/WebService/User.pm b/Bugzilla/WebService/User.pm index 12ca0a4ce1..8d36c3e027 100755 --- a/Bugzilla/WebService/User.pm +++ b/Bugzilla/WebService/User.pm @@ -37,7 +37,13 @@ use Bugzilla::Token; sub login { my ($self, $params) = @_; my $remember = $params->{remember}; - + + # Username and password params are required + foreach my $param ("login", "password") { + defined $params->{$param} + || ThrowCodeError('param_required', { param => $param }); + } + # Convert $remember from a boolean 0/1 value to a CGI-compatible one. if (defined($remember)) { $remember = $remember? 'on': ''; @@ -180,6 +186,10 @@ The username does not exist, or the password is wrong. The account has been disabled. A reason may be specified with the error. +=item 50 (Param Required) + +A login or password parameter was not provided. + =back =back