[imp] patch for imp/lib/Auth/imp.php

Amith Varghese amith at xalan.com
Wed Oct 22 14:28:41 PDT 2003


I got most of it from the other file and didn't think about cleaning it up.
Here's a shorter version (and hopefully better) patch

Thanks
Amith

Quoting Chuck Hagenbuch <chuck at horde.org>:

| Quoting Amith Varghese <amith at xalan.com>:
|
| > This patch enables hordeauth within IMP so that when you login, you don't
| > have to login twice when you have the hordeauth parameter set in
| servers.php.
|
| Why do you set these vars just to use them only once or twice?
|
| +                if (isset($hordeAuth)) {
| +                    $ptr = &$servers[$server_key];
| +                    $server     = $ptr['server'];
| +                    $realm      = $ptr['realm'];
| +                    $port       = $ptr['port'];
| +                    $protocol   = $ptr['protocol'];
| +                    $maildomain = $ptr['maildomain'];
| +                    $namespace  = $ptr['namespace'];
| +                    $folders    = $ptr['folders'];
| +                    if (strcasecmp($hordeAuth, 'full') == 0) {
| +                        $imapuser = Auth::getAuth();
| +                    } else {
| +                        $imapuser = Auth::getBareAuth();
| +                    }
| +                    $pass = Auth::getCredential('password');
| +                    $sessArray = array('realm'      => $realm,
| +                                       'port'       => $port,
| +                                       'protocol'   => $protocol,
| +                                       'maildomain' => $maildomain,
| +                                       'namespace'  => $namespace,
| +                                       'folders'    => $folders);
|
| ... the whole thing looks a bit messier than it has to be, and like it
| duplicates code elsewhere.
|
| -chuck
|
| --
| Charles Hagenbuch, <chuck at horde.org>
| Born right the first time.
|
| --
| IMP mailing list
| Frequently Asked Questions: http://horde.org/faq/
| To unsubscribe, mail: imp-unsubscribe at lists.horde.org
|
-------------- next part --------------
Index: imp/lib/Auth/imp.php
===================================================================
RCS file: /repository/imp/lib/Auth/imp.php,v
retrieving revision 1.6
diff -u -r1.6 imp.php
--- imp/lib/Auth/imp.php	16 Sep 2003 23:05:09 -0000	1.6
+++ imp/lib/Auth/imp.php	22 Oct 2003 21:43:19 -0000
@@ -68,6 +68,39 @@
     function authenticate($userID = null, $credentials = array(),
                           $login = false)
     {
+
+        // check for for hordeauth
+        if (empty($_SESSION['imp']['uniquser'])) {
+            if (IMP::canAutoLogin()) {
+                $server_key = IMP::getAutoLoginServer();
+
+                require IMP_BASE . '/config/servers.php';
+                $ptr = &$servers[$server_key];
+                if (isset($ptr['hordeauth'])) {
+
+                    if (strcasecmp($ptr['hordeauth'], 'full') == 0) {
+                        $imapuser = Auth::getAuth();
+                    } else {
+                        $imapuser = Auth::getBareAuth();
+                    }
+                    $pass = Auth::getCredential('password');
+
+                    require_once IMP_BASE . '/lib/Session.php';
+
+                    if (IMP_Session::createSession($imapuser, $pass, 
+                                                   $ptr['server'], $ptr)) {
+                        $entry = sprintf('Login success for %s [%s] to {%s:%s}',
+                                         $imapuser, $_SERVER['REMOTE_ADDR'],
+                                         $ptr['server'], $ptr['port']);
+                        Horde::logMessage($entry, __FILE__, __LINE__, 
+                                          PEAR_LOG_NOTICE);
+                        IMP_Session::loginTasks();
+                        return true;
+                    }
+                }
+            }
+        }
+
         if (empty($userID)) {
             if (empty($_SESSION['imp']['uniquser'])) {
                 return false;


More information about the imp mailing list