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

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

Fixes #2461
This commit is contained in:
mark_story 2012-01-10 20:32:12 -05:00
parent a8bc916104
commit 7877e7f997
2 changed files with 14 additions and 2 deletions

View file

@ -432,7 +432,7 @@ class AuthComponent extends Component {
*/ */
public function allow($action = null) { public function allow($action = null) {
$args = func_get_args(); $args = func_get_args();
if (empty($args)) { if (empty($args) || $action === null) {
$this->allowedActions = $this->_methods; $this->allowedActions = $this->_methods;
} else { } else {
if (isset($args[0]) && is_array($args[0])) { if (isset($args[0]) && is_array($args[0])) {
@ -458,7 +458,7 @@ class AuthComponent extends Component {
*/ */
public function deny($action = null) { public function deny($action = null) {
$args = func_get_args(); $args = func_get_args();
if (empty($args)) { if (empty($args) || $action === null) {
$this->allowedActions = array(); $this->allowedActions = array();
} else { } else {
if (isset($args[0]) && is_array($args[0])) { if (isset($args[0]) && is_array($args[0])) {

View file

@ -654,6 +654,18 @@ class AuthComponentTest extends CakeTestCase {
$this->Controller->request['action'] = 'login'; $this->Controller->request['action'] = 'login';
$this->assertFalse($this->Controller->Auth->startup($this->Controller)); $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));
} }
/** /**