Browse Source

Set authentication provider for stateless authentication too.

ADmad 10 years ago
parent
commit
f1f7c3f1b4

+ 1 - 0
src/Controller/Component/AuthComponent.php

@@ -696,6 +696,7 @@ class AuthComponent extends Component
         foreach ($this->_authenticateObjects as $auth) {
             $result = $auth->getUser($this->request);
             if (!empty($result) && is_array($result)) {
+                $this->_authenticationProvider = $auth;
                 $this->storage()->write($result);
                 return true;
             }

+ 5 - 0
tests/TestCase/Controller/Component/AuthComponentTest.php

@@ -1083,6 +1083,11 @@ class AuthComponentTest extends TestCase
         $result = $this->Auth->user();
         $this->assertEquals('mariano', $result['username']);
 
+        $this->assertInstanceOf(
+            'Cake\Auth\BasicAuthenticate',
+            $this->Auth->authenticationProvider()
+        );
+
         $result = $this->Auth->user('username');
         $this->assertEquals('mariano', $result);
         $this->assertFalse(isset($_SESSION));