Skip to content

Commit

Permalink
Changing AuthComponent::deny to accepts same param as AuthComponent::…
Browse files Browse the repository at this point in the history
…allow, tests added
  • Loading branch information
renan committed Aug 13, 2009
1 parent 2484245 commit c84b4cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 5 additions & 2 deletions cake/libs/controller/components/auth.php
Expand Up @@ -591,7 +591,7 @@ function __authType($auth = null) {
* Takes a list of actions in the current controller for which authentication is not required, or
* no parameters to allow all actions.
*
* @param string $action Controller action name
* @param mixed $action Controller action name or array of actions
* @param string $action Controller action name
* @param string ... etc.
* @return void
Expand All @@ -612,7 +612,7 @@ function allow() {
/**
* Removes items from the list of allowed actions.
*
* @param string $action Controller action name
* @param mixed $action Controller action name or array of actions
* @param string $action Controller action name
* @param string ... etc.
* @return void
Expand All @@ -621,6 +621,9 @@ function allow() {
*/
function deny() {
$args = func_get_args();
if (isset($args[0]) && is_array($args[0])) {
$args = $args[0];
}
foreach ($args as $arg) {
$i = array_search($arg, $this->allowedActions);
if (is_int($i)) {
Expand Down
11 changes: 10 additions & 1 deletion cake/tests/cases/libs/controller/components/auth.test.php
Expand Up @@ -777,7 +777,7 @@ function testAllowDenyAll() {
$this->Controller->Auth->initialize($this->Controller);

$this->Controller->Auth->allow('*');
$this->Controller->Auth->deny('add');
$this->Controller->Auth->deny('add', 'camelcase');

$this->Controller->params['action'] = 'delete';
$this->assertTrue($this->Controller->Auth->startup($this->Controller));
Expand All @@ -787,6 +787,15 @@ function testAllowDenyAll() {

$this->Controller->params['action'] = 'Add';
$this->assertFalse($this->Controller->Auth->startup($this->Controller));

$this->Controller->params['action'] = 'camelCase';
$this->assertFalse($this->Controller->Auth->startup($this->Controller));

$this->Controller->Auth->allow('*');
$this->Controller->Auth->deny(array('add', 'camelcase'));

$this->Controller->params['action'] = 'camelCase';
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
}

/**
Expand Down

0 comments on commit c84b4cf

Please sign in to comment.