Completed
Push — master ( 9c742a...1858b1 )
by Fèvre
14s
created

src/Controller/Component/AclAuthComponent.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace App\Controller\Component;
3
4
use Cake\Controller\Component\AuthComponent;
5
use Cake\Utility\Inflector;
6
7
class AclAuthComponent extends AuthComponent
8
{
9
10
    /**
11
     * Takes a list of actions in the current controller for which authentication is not required, or
12
     * no parameters to allow all actions.
13
     *
14
     * You can use allow with either an array or a simple string.
15
     *
16
     * `$this->Auth->allow('view');`
17
     * `$this->Auth->allow(['edit', 'add']);`
18
     * `$this->Auth->allow();` to allow all actions
19
     *
20
     * @param string|array $actions Controller action name or array of actions.
21
     *
22
     * @return void
23
     */
24
    public function allow($actions = null)
25
    {
26
        if ($actions === null) {
27
            $controller = $this->_registry->getController();
28
            $this->allowedActions = get_class_methods($controller);
29
30
            return;
31
        }
32
33
        $controller = Inflector::camelize($this->request['controller']);
34
        $action = Inflector::underscore($this->request['action']);
35
        if (!$this->session->read('Auth.User') ||
0 ignored issues
show
Deprecated Code introduced by
The property Cake\Controller\Component\AuthComponent::$session has been deprecated with message: 3.1.0 Will be removed in 4.0

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
36
            (isset($this->config('allowedActionsForBanned')[$controller]) &&
37
            in_array($action, array_map('strtolower', $this->config('allowedActionsForBanned')[$controller])))
38
        ) {
39
            $this->allowedActions = array_merge($this->allowedActions, (array)$actions);
40
        }
41
    }
42
}
43