From 808d1617ef17d8ae33cbc6533cf391c31123c0da Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 08 Jan 2011 03:37:55 -0500
Subject: [PATCH] - Fix fallback to LOGIN auth (broken in r4389)

---
 program/include/rcube_imap_generic.php |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index b11266f..166a106 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -768,10 +768,14 @@
                 $auth_methods = $auth_caps;
             }
             // RFC 2595 (LOGINDISABLED) LOGIN disabled when connection is not secure
-            if (($key = array_search('LOGIN', $auth_methods)) !== false
-                && $this->getCapability('LOGINDISABLED')
-            ) {
-                unset($auth_methods[$key]);
+            $login_disabled = $this->getCapability('LOGINDISABLED');
+            if (($key = array_search('LOGIN', $auth_methods)) !== false) {
+                if ($login_disabled) {
+                    unset($auth_methods[$key]);
+                }
+            }
+            else if (!$login_disabled) {
+                $auth_methods[] = 'LOGIN';
             }
         }
         else {

--
Gitblit v1.9.1