From: David Lawrence Date: Mon, 12 May 2014 19:14:53 +0000 (-0400) Subject: Backed out Bug 1001462 - Bug.search causes error when using simple token auth and... X-Git-Tag: bugzilla-4.4.5~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad99e9d01e648977f026bb8c5882ac6ab8d1717b;p=thirdparty%2Fbugzilla.git Backed out Bug 1001462 - Bug.search causes error when using simple token auth and specifying 'token' instead of 'Bugzilla_token' --- diff --git a/Bugzilla/WebService/User.pm b/Bugzilla/WebService/User.pm index b73a1c7592..b865e114c3 100644 --- a/Bugzilla/WebService/User.pm +++ b/Bugzilla/WebService/User.pm @@ -55,10 +55,16 @@ sub login { # Username and password params are required foreach my $param ("login", "password") { - (!defined $params->{$param} && !defined $params->{'Bugzilla_' . $param}) + defined $params->{$param} || ThrowCodeError('param_required', { param => $param }); } + # Make sure the CGI user info class works if necessary. + my $input_params = Bugzilla->input_params; + $input_params->{'Bugzilla_login'} = $params->{login}; + $input_params->{'Bugzilla_password'} = $params->{password}; + $input_params->{'Bugzilla_restrictlogin'} = $params->{restrict_login}; + my $user = Bugzilla->login(); my $result = { id => $self->type('int', $user->id) }; diff --git a/Bugzilla/WebService/Util.pm b/Bugzilla/WebService/Util.pm index 98602efc16..195de79e44 100644 --- a/Bugzilla/WebService/Util.pm +++ b/Bugzilla/WebService/Util.pm @@ -146,16 +146,18 @@ sub params_to_objects { sub fix_credentials { my ($params) = @_; - # Allow user to pass in login, password, restrict_login, and - # token as short-cuts to the longer versions. - $params->{'Bugzilla_login'} = delete $params->{'login'} - if exists $params->{'login'}; - $params->{'Bugzilla_password'} = delete $params->{'password'} - if exists $params->{'password'}; - $params->{'Bugzilla_restrictlogin'} = delete $params->{'restrict_login'} - if exists $params->{'restrict_login'}; - $params->{'Bugzilla_token'} = delete $params->{'token'} - if exists $params->{'token'}; + # Allow user to pass in login=foo&password=bar as a convenience + # even if not calling User.login. We also do not delete them as + # User.login requires "login" and "password". + if (exists $params->{'login'} && exists $params->{'password'}) { + $params->{'Bugzilla_login'} = $params->{'login'}; + $params->{'Bugzilla_password'} = $params->{'password'}; + } + # Allow user to pass token=12345678 as a convenience which becomes + # "Bugzilla_token" which is what the auth code looks for. + if (exists $params->{'token'}) { + $params->{'Bugzilla_token'} = $params->{'token'}; + } } __END__