Skip to content

Commit

Permalink
[mms] Fix handling authentication errors when they take place during …
Browse files Browse the repository at this point in the history
…an attempt to determine a mailbox's namespace.
  • Loading branch information
slusarz committed Oct 15, 2014
1 parent 6913598 commit 15e1e3c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
2 changes: 2 additions & 0 deletions imp/docs/CHANGES
Expand Up @@ -2,6 +2,8 @@
v6.2.3-git
----------

[mms] Fix handling authentication errors when they take place during an attempt
to determine a mailbox's namespace.
[mms] Fix some folder display issues when not using IMAP subscriptions in
dynamic view (Bug #13553).

Expand Down
16 changes: 9 additions & 7 deletions imp/lib/Imap.php
Expand Up @@ -717,9 +717,13 @@ public function __call($method, $params)
try {
$result = call_user_func_array(array($this->_ob, $method), $params);
} catch (Horde_Imap_Client_Exception $e) {
switch ($method) {
case 'getNamespaces':
return new Horde_Imap_Client_Namespace_List();
$error = new IMP_Imap_Exception($e);

if (!$error->authError()) {
switch ($method) {
case 'getNamespaces':
return new Horde_Imap_Client_Namespace_List();
}
}

Horde::log(
Expand All @@ -730,10 +734,8 @@ public function __call($method, $params)
),
'WARN'
);
$error = new IMP_Imap_Exception($e);
throw ($auth_e = $error->authException(false))
? $auth_e
: $error;

throw $error;
}

/* Special handling for various methods. */
Expand Down
42 changes: 22 additions & 20 deletions imp/lib/Imap/Exception.php
Expand Up @@ -53,43 +53,45 @@ public function notify($msg = null, $level = null, $force = false)
/**
* Generates an authentication exception.
*
* @param boolean $default Return exception, even if no code exists?
*
* @return Horde_Auth_Exception An authentication exception.
*/
public function authException($default = true)
public function authException()
{
$code = $this->authError();

return new Horde_Auth_Exception(
$this,
is_null($code) ? Horde_Auth::REASON_FAILED : $code
);
}

/**
* Returns the authentication error, if any.
*
* @return integer Authentication error, or null if exception not caused
* by auth error.
*/
public function authError()
{
switch ($this->getCode()) {
case self::LOGIN_AUTHENTICATIONFAILED:
case self::LOGIN_AUTHORIZATIONFAILED:
$code = Horde_Auth::REASON_BADLOGIN;
break;
return Horde_Auth::REASON_BADLOGIN;

case self::LOGIN_EXPIRED:
$code = Horde_Auth::REASON_EXPIRED;
break;
return Horde_Auth::REASON_EXPIRED;

case self::SERVER_CONNECT:
case self::LOGIN_UNAVAILABLE:
$code = Horde_Auth::REASON_MESSAGE;
break;
return Horde_Auth::REASON_MESSAGE;

case self::LOGIN_NOAUTHMETHOD:
case self::LOGIN_PRIVACYREQUIRED:
case self::LOGIN_TLSFAILURE:
$code = Horde_Auth::REASON_FAILED;
break;

default:
$code = $default
? Horde_Auth::REASON_FAILED
: null;
break;
return Horde_Auth::REASON_FAILED;
}

return is_null($code)
? null
: new Horde_Auth_Exception($this, $code);
return null;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions imp/package.xml
Expand Up @@ -33,6 +33,7 @@
</stability>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mms] Fix handling authentication errors when they take place during an attempt to determine a mailbox&apos;s namespace.
* [mms] Fix some folder display issues when not using IMAP subscriptions in dynamic view (Bug #13553).
* [mms] Fix accessing dynamic compose page when file uploads are not available (Bug #13580).
* [mms] Fix saving unique browser preferences for a specific backend in dynamic view.
Expand Down Expand Up @@ -3747,6 +3748,7 @@
<date>2014-09-05</date>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [mms] Fix handling authentication errors when they take place during an attempt to determine a mailbox&apos;s namespace.
* [mms] Fix some folder display issues when not using IMAP subscriptions in dynamic view (Bug #13553).
* [mms] Fix accessing dynamic compose page when file uploads are not available (Bug #13580).
* [mms] Fix saving unique browser preferences for a specific backend in dynamic view.
Expand Down

0 comments on commit 15e1e3c

Please sign in to comment.