diff --git a/src/Controller/Component/AuthComponent.php b/src/Controller/Component/AuthComponent.php index 9ced46e9ec5..b9084d8d0af 100644 --- a/src/Controller/Component/AuthComponent.php +++ b/src/Controller/Component/AuthComponent.php @@ -582,17 +582,16 @@ public function mapActions(array $map = array()) { } /** - * Log a user in. + * Set provided user info to session as logged in user. * - * The provided user data will be stored as the logged in user. The user record - * is written to the session key specified in AuthComponent::$sessionKey. Logging - * in will also change the session id in order to help mitigate session replays. + * The user recordis written to the session key specified in AuthComponent::$sessionKey. + * Thehe session id will also be changed in order to help mitigate session replays. * * @param array $user Array of user data. * @return void * @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in */ - public function login(array $user) { + public function setUser(array $user) { $this->_setDefaults(); $this->session->renew(); diff --git a/tests/TestCase/Controller/Component/AuthComponentTest.php b/tests/TestCase/Controller/Component/AuthComponentTest.php index ae08709b746..8570cda1610 100644 --- a/tests/TestCase/Controller/Component/AuthComponentTest.php +++ b/tests/TestCase/Controller/Component/AuthComponentTest.php @@ -722,7 +722,7 @@ public function testDefaultToLoginRedirect() { $Request->env('HTTP_REFERER', false); $this->Auth->request->addParams(Router::parse($url)); $this->Auth->config('authorize', ['Controller']); - $this->Auth->login(array('username' => 'mariano', 'password' => 'cake')); + $this->Auth->setUser(array('username' => 'mariano', 'password' => 'cake')); $this->Auth->config('loginRedirect', [ 'controller' => 'something', 'action' => 'else' ]); @@ -759,7 +759,7 @@ public function testRedirectToUnauthorizedRedirect() { ]); $this->Auth->request->addParams(Router::parse($url)); $this->Auth->config('authorize', ['Controller']); - $this->Auth->login(array('username' => 'admad', 'password' => 'cake')); + $this->Auth->setUser(array('username' => 'admad', 'password' => 'cake')); $expected = ['controller' => 'no_can_do', 'action' => 'jack']; $this->Auth->config('unauthorizedRedirect', $expected); @@ -796,7 +796,7 @@ public function testRedirectToUnauthorizedRedirectSuppressedAuthError() { $this->Auth->request = $Request = new Request($url); $this->Auth->request->addParams(Router::parse($url)); $this->Auth->config('authorize', ['Controller']); - $this->Auth->login(array('username' => 'admad', 'password' => 'cake')); + $this->Auth->setUser(array('username' => 'admad', 'password' => 'cake')); $expected = ['controller' => 'no_can_do', 'action' => 'jack']; $this->Auth->config('unauthorizedRedirect', $expected); $this->Auth->config('authError', false); @@ -833,7 +833,7 @@ public function testForbiddenException() { 'authorize' => ['Controller'], 'unauthorizedRedirect' => false ]); - $this->Auth->login(array('username' => 'baker', 'password' => 'cake')); + $this->Auth->setUser(array('username' => 'baker', 'password' => 'cake')); $response = new Response(); $Controller = $this->getMock( @@ -1093,11 +1093,11 @@ public function testMapActionsDelegation() { } /** - * test logging in. + * test setting user info to session. * * @return void */ - public function testLogin() { + public function testSetUser() { $this->Auth->session = $this->getMock( 'Cake\Network\Session', array('renew', 'write') @@ -1112,15 +1112,15 @@ public function testLogin() { ->method('write') ->with($this->Auth->sessionKey, $user); - $this->Auth->login($user); + $this->Auth->setUser($user); } /** - * testGettingUserAfterLogin + * testGettingUserAfterSetUser * * @return void */ - public function testGettingUserAfterLogin() { + public function testGettingUserAfterSetUser() { $this->assertFalse((bool)$this->Auth->user()); $user = array( @@ -1129,7 +1129,7 @@ public function testGettingUserAfterLogin() { 'created' => new \DateTime('2007-03-17 01:16:23'), 'updated' => new \DateTime('2007-03-17 01:18:31') ); - $this->Auth->login($user); + $this->Auth->setUser($user); $this->assertTrue((bool)$this->Auth->user()); $this->assertEquals($user['username'], $this->Auth->user('username')); }