]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 553770: Make the JSON-RPC WebService throw a proper error when you don't
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Tue, 23 Mar 2010 23:08:48 +0000 (16:08 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Tue, 23 Mar 2010 23:08:48 +0000 (16:08 -0700)
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
Bugzilla/WebService/Constants.pm
template/en/default/global/user-error.html.tmpl

index 407582af4fc10b639a208d81db694a27964ebd97..8e877b95136392c0f75ca85cbdb407ab6f656d77 100644 (file)
@@ -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();
index a51389faa8460947ea2ac678f4fc98f004313da0..c7c52fecef221fad0847c33644c07eb6eb473036 100644 (file)
@@ -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 {
index 6bf904a94eadc88bdd46388e1fe2ea68aa3d6396..4b1a82be642eab5e8fe74de65c9729200c04d9a7 100644 (file)
     You can't use %user% without being logged in, because %user% refers
     to your login name, which we don't know.
 
+  [% ELSIF error == "login_required" %]
+    [%# Used for non-web-based LOGIN_REQUIRED situations. %]
+    You must log in before using this part of [% terms.Bugzilla %].
+
   [% ELSIF error == "migrate_config_created" %]
     The file <kbd>[% file FILTER html %]</kbd> contains configuration
     variables that must be set before continuing with the migration.