Skip to content

Commit

Permalink
Make allow(null) and deny(null) consistent with no args.
Browse files Browse the repository at this point in the history
No arguments and a single null should be handled the same.

Fixes #2461
  • Loading branch information
markstory committed Jan 11, 2012
1 parent a8bc916 commit 7877e7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Controller/Component/AuthComponent.php
Expand Up @@ -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])) {
Expand All @@ -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])) {
Expand Down
12 changes: 12 additions & 0 deletions lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php
Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 7877e7f

Please sign in to comment.