From 7877e7f997cf4592a5f3eb743069db605cb6561a Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 10 Jan 2012 20:32:12 -0500 Subject: [PATCH] Make allow(null) and deny(null) consistent with no args. No arguments and a single null should be handled the same. Fixes #2461 --- lib/Cake/Controller/Component/AuthComponent.php | 4 ++-- .../Case/Controller/Component/AuthComponentTest.php | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 697d318157a..0b5aea1d6a4 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -432,7 +432,7 @@ public function constructAuthorize() { */ public function allow($action = null) { $args = func_get_args(); - if (empty($args)) { + if (empty($args) || $action === null) { $this->allowedActions = $this->_methods; } else { if (isset($args[0]) && is_array($args[0])) { @@ -458,7 +458,7 @@ public function allow($action = null) { */ public function deny($action = null) { $args = func_get_args(); - if (empty($args)) { + if (empty($args) || $action === null) { $this->allowedActions = array(); } else { if (isset($args[0]) && is_array($args[0])) { diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 486bf88a909..f80e8ff8131 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -654,6 +654,18 @@ public function testAllowDenyAll() { $this->Controller->request['action'] = 'login'; $this->assertFalse($this->Controller->Auth->startup($this->Controller)); + + $this->Controller->Auth->deny(); + $this->Controller->Auth->allow(null); + + $this->Controller->request['action'] = 'camelCase'; + $this->assertTrue($this->Controller->Auth->startup($this->Controller)); + + $this->Controller->Auth->allow(); + $this->Controller->Auth->deny(null); + + $this->Controller->request['action'] = 'camelCase'; + $this->assertFalse($this->Controller->Auth->startup($this->Controller)); } /**