Skip to content

Commit

Permalink
Add Response as argument for auth storage classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed May 31, 2015
1 parent 34d2472 commit 84c599a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Auth/Storage/SessionStorage.php
Expand Up @@ -16,6 +16,7 @@

use Cake\Core\InstanceConfigTrait;
use Cake\Network\Request;
use Cake\Network\Response;

/**
* Session based persistent storage for authenticated user record.
Expand Down Expand Up @@ -55,9 +56,10 @@ class SessionStorage implements StorageInterface
* Constructor.
*
* @param \Cake\Network\Request $request Request instance.
* @param \Cake\Netowrk\Response $respose Response instance.
* @param array $config Configuration list.
*/
public function __construct(Request $request, array $config = [])
public function __construct(Request $request, Response $respose, array $config = [])
{
$this->_session = $request->session();
$this->config($config);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Component/AuthComponent.php
Expand Up @@ -813,7 +813,7 @@ public function storage(StorageInterface $storage = null)
if (!class_exists($className)) {
throw new Exception(sprintf('Auth storage adapter "%s" was not found.', $class));
}
$this->_storage = new $className($this->request, $config);
$this->_storage = new $className($this->request, $this->response, $config);

return $this->_storage;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/TestCase/Auth/Storage/SessionStorageTest.php
Expand Up @@ -16,6 +16,7 @@

use Cake\Auth\Storage\SessionStorage;
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\TestSuite\TestCase;

/**
Expand All @@ -36,7 +37,8 @@ public function setUp()

$this->session = $this->getMock('Cake\Network\Session');
$this->request = new Request(['session' => $this->session]);
$this->storage = new SessionStorage($this->request, ['key' => 'Auth.AuthUser']);
$this->response = new Response();
$this->storage = new SessionStorage($this->request, $this->response, ['key' => 'Auth.AuthUser']);
$this->user = ['id' => 1];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Controller/Component/AuthComponentTest.php
Expand Up @@ -1117,7 +1117,7 @@ public function testSetUser()
$storage = $this->getMock(
'Cake\Auth\Storage\SessionStorage',
['write'],
[$this->Auth->request]
[$this->Auth->request, $this->Auth->response]
);
$this->Auth->storage($storage);

Expand Down

0 comments on commit 84c599a

Please sign in to comment.