Skip to content

Commit

Permalink
Hacky: for 'fallback' auth used with AJAX, need to store authenticati…
Browse files Browse the repository at this point in the history
…on exception in case non-auth access is not available

Otherwise, appInitFailure() is never triggered for app (i.e. IMP auto
draft save is not triggered).

For H6, need cleaner way to bootstrap an access and/or route all logout
events through a single object.  Right now, Horde_ErrorHandler catches
auth exceptions, but it does redirects only.  Should refactor so it
handles non-interactive accessess too.
  • Loading branch information
slusarz authored and mrubinsk committed Nov 14, 2013
1 parent ef7243c commit 35c667e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions framework/Core/lib/Horde/Core/Ajax/Response/HordeCore/NoAuth.php
Expand Up @@ -39,6 +39,19 @@ public function __construct($app, $error = Horde_Auth::REASON_FAILED)
$this->_error = $error;
}

/**
*/
public function send()
{
global $registry;

if (!empty($registry->authException)) {
$registry->getApiInstance($this->_app, 'application')->appInitFailure($registry->authException);
}

parent::send();
}

/**
*/
protected function _jsonData()
Expand Down
Expand Up @@ -31,6 +31,19 @@ public function __construct($app)
$this->_app = $app;
}

/**
*/
public function send()
{
global $registry;

if (!empty($registry->authException)) {
$registry->getApiInstance($this->_app, 'application')->appInitFailure($registry->authException);
}

parent::send();
}

/**
*/
protected function _jsonData()
Expand Down
13 changes: 13 additions & 0 deletions framework/Core/lib/Horde/Registry.php
Expand Up @@ -50,6 +50,18 @@ class Horde_Registry implements Horde_Shutdown_Task
*/
public $applications = array();

/**
* Original authentication exception. Set if 'fallback' auth is used, and
* authentication fails.
*
* @since 2.11.0
* @todo Fix this up for H6 (framework needs to do better job of
* supporting bootstrapping before authentication).
*
* @var Exception
*/
public $authException;

/**
* A flag that is set once the basic horde application has been
* minimally configured.
Expand Down Expand Up @@ -283,6 +295,7 @@ static public function appInit($app, array $args = array())
} catch (Horde_Exception_PushApp $e) {
if ($fallback_auth) {
$args['authentication'] = 'none';
$registry->authException = $e;
return self::appInit($app, $args);
}

Expand Down

0 comments on commit 35c667e

Please sign in to comment.