]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 358354: WebService should perform a login in xmlrpc.cgi
authormkanat%bugzilla.org <>
Mon, 5 Feb 2007 00:23:20 +0000 (00:23 +0000)
committermkanat%bugzilla.org <>
Mon, 5 Feb 2007 00:23:20 +0000 (00:23 +0000)
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat

Bugzilla/WebService.pm
Bugzilla/WebService/Constants.pm
Bugzilla/WebService/User.pm
xmlrpc.cgi

index b38596f2a6ee4380518f57410ee84c4106221a08..0f32e74be3fd9ce78af94440e62792a91c2ba036 100755 (executable)
@@ -41,6 +41,13 @@ sub datetime_format {
     return $iso_datetime;
 }
 
+sub handle_login {
+    my ($self, $module, $method) = @_;
+    my $exempt = LOGIN_EXEMPT->{$module};
+    return if $exempt && grep { $_ eq $method } @$exempt;
+    Bugzilla->login;
+}
+
 package Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI;
 
 use strict;
index d1f816c84cf4e7bfd3e5d1f4c61d3cd3ff4712f0..39d25298d2d473cf042e4ab906c1705557e012b4 100755 (executable)
@@ -27,6 +27,8 @@ use base qw(Exporter);
 
     ERROR_AUTH_NODATA
     ERROR_UNIMPLEMENTED
+
+    LOGIN_EXEMPT
 );
 
 # This maps the error names in global/*-error.html.tmpl to numbers.
@@ -98,4 +100,13 @@ use constant ERROR_AUTH_NODATA   => 410;
 use constant ERROR_UNIMPLEMENTED => 910;
 use constant ERROR_GENERAL       => 999;
 
+# For some methods, we shouldn't call Bugzilla->login before we call them.
+# This is a hash--package names pointing to an arrayref of method names.
+use constant LOGIN_EXEMPT => {
+    # Callers may have to know the Bugzilla version before logging in,
+    # even on a requirelogin installation.
+    Bugzilla => ['version'],
+    User     => ['offer_account_by_email', 'login'],
+};
+
 1;
index 74e8f8e037f6268f32497e54b25311197047053f..db02ff75ae65f6d04d1fc6f1869c0992add7c10f 100755 (executable)
@@ -60,10 +60,7 @@ sub login {
 
 sub logout {
     my $self = shift;
-
-    Bugzilla->login(LOGIN_OPTIONAL);
     Bugzilla->logout;
-
     return undef;
 }
 
index e4dfacc4393b8cc45dd9481d2c5605d7e49a0343..c17cab86c3e8ce1a49da9cb9ef076ee272157270 100755 (executable)
@@ -35,4 +35,5 @@ my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI
                      'User'     => 'Bugzilla::WebService::User',
                      'Product'  => 'Bugzilla::WebService::Product',
                     })
+    ->on_action(\&Bugzilla::WebService::handle_login)
     ->handle;