From ccb36aaa7adc9d07d74dd5c2e64763cc8749cf4c Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Tue, 23 Mar 2010 16:08:48 -0700 Subject: Bug 553770: Make the JSON-RPC WebService throw a proper error when you don't provide login credentials on a LOGIN_REQUIRED page. (Before this, it was attempting to display the HTML login page to JSON-RPC clients.) r=dkl, a=mkanat --- Bugzilla/Auth/Login/CGI.pm | 6 ++---- Bugzilla/WebService/Constants.pm | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Auth/Login/CGI.pm b/Bugzilla/Auth/Login/CGI.pm index 407582af4..8e877b951 100644 --- a/Bugzilla/Auth/Login/CGI.pm +++ b/Bugzilla/Auth/Login/CGI.pm @@ -57,10 +57,8 @@ sub fail_nodata { my $cgi = Bugzilla->cgi; my $template = Bugzilla->template; - if (Bugzilla->error_mode == Bugzilla::Constants::ERROR_MODE_DIE_SOAP_FAULT) { - die SOAP::Fault - ->faultcode(ERROR_AUTH_NODATA) - ->faultstring('Login Required'); + if (Bugzilla->usage_mode != USAGE_MODE_BROWSER) { + ThrowUserError('login_required'); } print $cgi->header(); diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm index a51389faa..c7c52fece 100644 --- a/Bugzilla/WebService/Constants.pm +++ b/Bugzilla/WebService/Constants.pm @@ -24,7 +24,6 @@ our @EXPORT = qw( WS_ERROR_CODE ERROR_UNKNOWN_FATAL ERROR_UNKNOWN_TRANSIENT - ERROR_AUTH_NODATA WS_DISPATCH ); @@ -99,6 +98,9 @@ use constant WS_ERROR_CODE => { extern_id_conflict => -303, auth_failure => 304, + # Except, historically, AUTH_NODATA, which is 410. + login_required => 410, + # User errors are 500-600. account_exists => 500, illegal_email_address => 501, @@ -120,7 +122,6 @@ use constant WS_ERROR_CODE => { use constant ERROR_UNKNOWN_FATAL => -32000; use constant ERROR_UNKNOWN_TRANSIENT => 32000; -use constant ERROR_AUTH_NODATA => 410; use constant ERROR_GENERAL => 999; sub WS_DISPATCH { -- cgit v1.2.3-24-g4f1b