From a20f90cd2dbced6dc0532d8d76c4b94c3ce3c2e0 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Fri, 6 Feb 2015 15:20:01 -0500 Subject: [PATCH] Marginally better error handling for 401 in REST controller --- .../application/controllers/plugins/Acl_plugin.php | 4 ++-- airtime_mvc/public/index.php | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/plugins/Acl_plugin.php b/airtime_mvc/application/controllers/plugins/Acl_plugin.php index 635882391..5f6b64959 100644 --- a/airtime_mvc/application/controllers/plugins/Acl_plugin.php +++ b/airtime_mvc/application/controllers/plugins/Acl_plugin.php @@ -119,12 +119,12 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract // we need to do API key verification if ($request->getModuleName() == "rest") { if (!$this->verifyAuth()) { - $this->denyAccess(); + //$this->denyAccess(); //$this->getResponse()->sendResponse(); //$r->gotoSimpleAndExit('index', 'login', $request->getModuleName()); //die(); - return; + throw new Zend_Controller_Exception("hi", 401); } } diff --git a/airtime_mvc/public/index.php b/airtime_mvc/public/index.php index 7a99db0b3..f9c6e4fe4 100644 --- a/airtime_mvc/public/index.php +++ b/airtime_mvc/public/index.php @@ -92,11 +92,17 @@ try { } } catch (Exception $e) { - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); + if ($e->getCode() == 401) + { + header($_SERVER['SERVER_PROTOCOL'] . ' 401 Unauthorized', true, 401); + return; + } + header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); Logging::error($e->getMessage()); + if (VERBOSE_STACK_TRACE) { - echo $e->getMessage(); + echo $e->getMessage() . '
'; echo "
";
         echo $e->getTraceAsString();
         echo "
";