From 651c084c9cc2a867ffd6a5e9fd76486cb41fc032 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 21 Jul 2009 22:41:10 -0600 Subject: [PATCH] Various auth fixes. Use correct username when authenticating Fix generation of initial URL when it is mailbox view Use better "is currently authenticated" function Correctly set realm'ed username as Horde username --- imp/lib/Auth.php | 13 ++++++++----- imp/lib/IMP.php | 20 +++++++++++++++----- imp/lib/api.php | 4 ++++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php index 4d03cf018..09cb94601 100644 --- a/imp/lib/Auth.php +++ b/imp/lib/Auth.php @@ -217,7 +217,7 @@ class IMP_Auth } /* Determine the unique user name. */ - if (Horde_Auth::isAuthenticated()) { + if (Horde_Auth::getAuth()) { $sess['uniquser'] = Horde_Auth::removeHook(Horde_Auth::getAuth()); } else { $sess['uniquser'] = $credentials['userid']; @@ -231,7 +231,7 @@ class IMP_Auth self::authenticate(array( 'password' => $credentials['password'], 'server' => $credentials['server'], - 'userid' => $sess['uniquser'] + 'userid' => $credentials['userid'] )); } catch (Horde_Auth_Exception $e) { unset($_SESSION['imp']); @@ -460,9 +460,12 @@ class IMP_Auth break; default: - // TODO: Directly load mailbox.php - header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('mailbox.php', true), array('mailbox' => $init_url))); - exit; + $page = 'mailbox.php'; + if ($url) { + return Horde_Util::addParameter(Horde::applicationUrl($page, true), array('mailbox' => $init_url)); + } + $GLOBALS['imp_mbox'] = IMP::getCurrentMailboxInfo($init_url); + break; } } diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 3010f9237..ea0c6f4c7 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -1119,6 +1119,8 @@ class IMP /** * Process mailbox/index information for current page load. * + * @param boolean $mbox Use this mailbox, instead of form data. + * * @return array Array with the following elements: *
      * 'mailbox' - The current active mailbox (may be search mailbox).
@@ -1126,13 +1128,21 @@ class IMP
      * 'index' - The IMAP message index.
      * 
*/ - static public function getCurrentMailboxInfo() + static public function getCurrentMailboxInfo($mbox = null) { - $mbox = Horde_Util::getFormData('mailbox'); + if (is_null($mbox)) { + $mbox = Horde_Util::getFormData('mailbox'); + return array( + 'mailbox' => empty($mbox) ? 'INBOX' : $mbox, + 'thismailbox' => Horde_Util::getFormData('thismailbox', $mbox), + 'index' => Horde_Util::getFormData('index') + ); + } + return array( - 'mailbox' => empty($mbox) ? 'INBOX' : $mbox, - 'thismailbox' => Horde_Util::getFormData('thismailbox', $mbox), - 'index' => Horde_Util::getFormData('index') + 'mailbox' => $mbox, + 'thismailbox' => $mbox, + 'index' => null ); } diff --git a/imp/lib/api.php b/imp/lib/api.php index f34310c7d..918d078b7 100644 --- a/imp/lib/api.php +++ b/imp/lib/api.php @@ -676,6 +676,10 @@ function _imp_authAuthenticate($userId, $credentials) $conf['cookie']['domain']); $_SESSION['imp']['view'] = $view; + + /* Set the Horde ID, since it may have been altered by the 'realm' + * setting. */ + $credentials['auth_ob']->setCredential('userId', $_SESSION['imp']['uniquser']); } } -- 2.11.0