Marginally better error handling for 401 in REST controller

This commit is contained in:
Albert Santoni 2015-02-06 15:20:01 -05:00
parent 7bf96e09a5
commit a20f90cd2d
2 changed files with 10 additions and 4 deletions

View File

@ -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);
}
}

View File

@ -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() . '<br>';
echo "<pre>";
echo $e->getTraceAsString();
echo "</pre>";