Skip to content

Commit

Permalink
Bug: 15077 Support case where auth server is unavailable.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Oct 25, 2021
1 parent 29af5e3 commit ea5a15f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/Horde/ActiveSync.php
Expand Up @@ -310,6 +310,7 @@ class Horde_ActiveSync
/* Auth failure reasons */
const AUTH_REASON_USER_DENIED = 'user';
const AUTH_REASON_DEVICE_DENIED = 'device';
const AUTH_REASON_UNAVAILABLE = 'unavailable';

/* Internal flag indicates all possible fields are ghosted */
const ALL_GHOSTED = 'allghosted';
Expand Down Expand Up @@ -409,9 +410,9 @@ class Horde_ActiveSync
/**
* Global error flag.
*
* @var boolean
* @var int ActiveSync global status code.
*/
protected $_globalError = false;
protected $_globalError = 0;

/**
* Process id (used in logging).
Expand Down Expand Up @@ -574,6 +575,12 @@ public function authenticate(Horde_ActiveSync_Credentials $credentials)
$this->_globalError = Horde_ActiveSync_Status::SYNC_NOT_ALLOWED;
} elseif ($result === self::AUTH_REASON_DEVICE_DENIED) {
$this->_globalError = Horde_ActiveSync_Status::DEVICE_BLOCKED_FOR_USER;
} elseif ($result === self::AUTH_REASON_UNAVAILABLE) {
$this->_globalError = Horde_ActiveSync_Status::SERVER_ERROR_RETRY;
if ($this->getProtocolVersion() < Horde_ActiveSync::VERSION_FOURTEEN) {
// Horde_ActiveSync_STATUS_SERVER_ERROR_RETRY only supported >= 14.0
return false;
}
} elseif ($result !== true) {
$this->_globalError = Horde_ActiveSync_Status::DENIED;
}
Expand Down Expand Up @@ -748,7 +755,7 @@ public function handleRequest($cmd, $devId)
$this->activeSyncHeader();
$this->versionHeader();
$this->commandsHeader();
throw new Horde_Exception_AuthenticationFailure();
throw new Horde_Exception_AuthenticationFailure('', $this->_globalError);
}

self::$_logger->info(sprintf(
Expand Down

0 comments on commit ea5a15f

Please sign in to comment.