Commit d26bc5f1 authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 358354: WebService should perform a login in xmlrpc.cgi

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
parent 5d158911
......@@ -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;
......
......@@ -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;
......@@ -60,10 +60,7 @@ sub login {
sub logout {
my $self = shift;
Bugzilla->login(LOGIN_OPTIONAL);
Bugzilla->logout;
return undef;
}
......
......@@ -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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment