]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1001462: Bug.search causes error when using simple token auth and specifying...
authorDavid Lawrence <dkl@mozilla.com>
Wed, 12 Nov 2014 16:58:12 +0000 (16:58 +0000)
committerDavid Lawrence <dkl@mozilla.com>
Wed, 12 Nov 2014 16:58:12 +0000 (16:58 +0000)
r=glob,a=glob

Bugzilla/WebService/User.pm
Bugzilla/WebService/Util.pm

index b865e114c384c6d8e64b6d2995da144904710872..171017eb79a14f5b12e9a198a6f4a69414e44e4a 100644 (file)
@@ -53,27 +53,20 @@ use constant MAPPED_RETURNS => {
 sub login {
     my ($self, $params) = @_;
 
+    # Check to see if we are already logged in
+    my $user = Bugzilla->user;
+    if ($user->id) {
+        return $self->_login_to_hash($user);
+    }
+
     # Username and password params are required 
     foreach my $param ("login", "password") {
-        defined $params->{$param} 
+        (defined $params->{$param} || defined $params->{'Bugzilla_' . $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) };
-
-    if ($user->{_login_token}) {
-        $result->{'token'} = $user->id . "-" . $user->{_login_token};
-    }
-
-    return $result;
+    $user = Bugzilla->login();
+    return $self->_login_to_hash($user);
 }
 
 sub logout {
@@ -384,6 +377,15 @@ sub _report_to_hash {
     return $item;
 }
 
+sub _login_to_hash {
+    my ($self, $user) = @_;
+    my $item = { id => $self->type('int', $user->id) };
+    if ($user->{_login_token}) {
+        $item->{'token'} = $user->id . "-" . $user->{_login_token};
+    }
+    return $item;
+}
+
 1;
 
 __END__
index 195de79e44406bb795c15d43d34b9a9026d1896f..c7d63b3366082cbaaf4b53bf4e4260b88c9fed54 100644 (file)
@@ -150,13 +150,13 @@ sub fix_credentials {
     # 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'};
+        $params->{'Bugzilla_login'}    = delete $params->{'login'};
+        $params->{'Bugzilla_password'} = delete $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'};
+        $params->{'Bugzilla_token'} = delete $params->{'token'};
     }
 }