From ed122c70f46a6e591727e6c8743a009f4ac7bf5e Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 20 Jan 2011 21:22:54 -0500 Subject: [PATCH] Removing custom request reversal code, and using Router::reverse() Removing dead tests that are covered by Router tests. Removing check for TestsController, it hasn't existed in forever. --- cake/libs/controller/components/auth.php | 21 ++++--------------- .../libs/controller/components/auth.test.php | 15 +------------ 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 1361a8797..d398392de 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -288,11 +288,7 @@ class AuthComponent extends Component { * @return boolean */ public function startup($controller) { - $isErrorOrTests = ( - strtolower($controller->name) == 'cakeerror' || - (strtolower($controller->name) == 'tests' && Configure::read('debug') > 0) - ); - if ($isErrorOrTests) { + if ($controller->name == 'CakeError') { return true; } @@ -342,12 +338,7 @@ class AuthComponent extends Component { if (!$this->user()) { if (!$request->is('ajax')) { $this->flash($this->authError); - if (!empty($request->query) && count($request->query) >= 2) { - $query = $request->query; - unset($query['url'], $query['ext']); - $url .= Router::queryString($query, array()); - } - $this->Session->write('Auth.redirect', $url); + $this->Session->write('Auth.redirect', Router::reverse($request)); $controller->redirect($loginAction); return false; } elseif (!empty($this->ajaxLogin)) { @@ -361,11 +352,7 @@ class AuthComponent extends Component { } } - if (!$this->authorize) { - return true; - } - - if ($this->isAuthorized()) { + if (empty($this->authorize) || $this->isAuthorized()) { return true; } @@ -519,7 +506,7 @@ class AuthComponent extends Component { /** * Log a user in. If a $user is provided that data will be stored as the logged in user. If `$user` is empty or not - * specified, POST data from the current request will be used to identify a user. If the login was successful, + * specified, the request will be used to identify a user. If the identification was successful, * the user record is written to the session key specified in AuthComponent::$sessionKey. * * @param mixed $user Either an array of user data, or null to identify a user using the current request. diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 685c48740..7783c5d29 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -943,17 +943,6 @@ class AuthTest extends CakeTestCase { $this->Controller->Session->delete('Auth'); - $this->Controller->request->query['url'] = 'admin/'; - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->loginRedirect = null; - $this->Controller->Auth->startup($this->Controller); - $expected = Router::normalize('admin/'); - $this->assertTrue($this->Controller->Session->check('Message.auth')); - $this->assertEqual($expected, $this->Controller->Auth->redirect()); - - $this->Controller->Session->delete('Auth'); - //empty referer no session $_SERVER['HTTP_REFERER'] = false; $_ENV['HTTP_REFERER'] = false; @@ -969,7 +958,6 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->authorize = 'controller'; - $this->Controller->request['testControllerAuth'] = true; $this->Controller->Auth->loginAction = array( 'controller' => 'AuthTest', 'action' => 'login' @@ -1041,8 +1029,7 @@ class AuthTest extends CakeTestCase { $_GET = array( 'url' => '/posts/index/29', 'print' => 'true', - 'refer' => 'menu', - 'ext' => 'html' + 'refer' => 'menu' ); $this->Controller->Session->delete('Auth'); $url = '/posts/index/29';