Allow the drivers to rewrite the login credentials again.
authorGunnar Wrobel <p@rdus.de>
Wed, 1 Dec 2010 21:01:13 +0000 (22:01 +0100)
committerGunnar Wrobel <p@rdus.de>
Wed, 1 Dec 2010 21:10:18 +0000 (22:10 +0100)
framework/Auth/lib/Horde/Auth/Base.php
framework/Auth/test/Horde/Auth/Unit/KolabTest.php

index c1fe008..63ed925 100644 (file)
@@ -106,8 +106,9 @@ abstract class Horde_Auth_Base
         $userId = trim($userId);
 
         try {
+            $this->_credentials['userId'] = $userId;
             $this->_authenticate($userId, $credentials);
-            $this->setCredential('userId', $userId);
+            $this->setCredential('userId', $this->_credentials['userId']);
             $this->setCredential('credentials', $credentials);
             return true;
         } catch (Horde_Auth_Exception $e) {
index 703dfe1..7ad0c01 100644 (file)
@@ -77,4 +77,19 @@ class Horde_Auth_Unit_KolabTest extends Horde_Auth_TestCase
             $this->assertEquals(Horde_Auth::REASON_FAILED, $e->getCode());
         }
     }
+
+    public function testUidRewrite()
+    {
+        $this->kolab->expects($this->once())
+            ->method('connect')
+            ->with('user', array('password' => 'password'))
+            ->will($this->returnValue(null));
+        $this->kolab->expects($this->once())
+            ->method('getMail')
+            ->will($this->returnValue('user@example.com'));
+        $this->driver->authenticate('user', array('password' => 'password'));
+        $this->assertEquals(
+            'user@example.com', $this->driver->getCredential('userId')
+        );
+    }
 }
\ No newline at end of file