Skip to content
Browse files

Make allow(null) and deny(null) consistent with no args.

No arguments and a single null should be handled the same.

Fixes #2461
  • Loading branch information...
1 parent a8bc916 commit 7877e7f997cf4592a5f3eb743069db605cb6561a @markstory markstory committed
View
4 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])) {
View
12 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));
}
/**

0 comments on commit 7877e7f

Please sign in to comment.
Something went wrong with that request. Please try again.