giumar /
fortunecookies
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | |||
| 3 | declare(strict_types=1); |
||
|
0 ignored issues
–
show
|
|||
| 4 | /** |
||
|
0 ignored issues
–
show
|
|||
| 5 | * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) |
||
| 6 | * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) |
||
|
0 ignored issues
–
show
|
|||
| 7 | * |
||
| 8 | * Licensed under The MIT License |
||
| 9 | * For full copyright and license information, please see the LICENSE.txt |
||
| 10 | * Redistributions of files must retain the above copyright notice. |
||
| 11 | * |
||
| 12 | * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) |
||
|
0 ignored issues
–
show
|
|||
| 13 | * @link https://cakephp.org CakePHP(tm) Project |
||
|
0 ignored issues
–
show
|
|||
| 14 | * @since 0.2.9 |
||
|
0 ignored issues
–
show
|
|||
| 15 | * @license https://opensource.org/licenses/mit-license.php MIT License |
||
|
0 ignored issues
–
show
|
|||
| 16 | */ |
||
|
0 ignored issues
–
show
|
|||
| 17 | |||
| 18 | namespace App\Controller; |
||
| 19 | |||
| 20 | use Cake\Controller\Controller; |
||
| 21 | use Cake\Event\EventInterface; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Application Controller |
||
| 25 | * |
||
| 26 | * Add your application-wide methods in the class below, your controllers |
||
| 27 | * will inherit them. |
||
| 28 | * |
||
| 29 | * @link https://book.cakephp.org/4/en/controllers.html#the-app-controller |
||
| 30 | */ |
||
|
0 ignored issues
–
show
|
|||
| 31 | class AppController extends Controller { |
||
|
0 ignored issues
–
show
|
|||
| 32 | |||
| 33 | /** |
||
| 34 | * Initialization hook method. |
||
| 35 | * |
||
| 36 | * Use this method to add common initialization code like loading components. |
||
|
0 ignored issues
–
show
|
|||
| 37 | * |
||
| 38 | * e.g. `$this->loadComponent('FormProtection');` |
||
| 39 | * |
||
| 40 | * @return void |
||
|
0 ignored issues
–
show
|
|||
| 41 | */ |
||
| 42 | 19 | public function initialize(): void { |
|
|
0 ignored issues
–
show
|
|||
| 43 | 19 | parent::initialize(); |
|
| 44 | |||
| 45 | 19 | $this->loadComponent('RequestHandler'); |
|
| 46 | 19 | $this->loadComponent('Flash'); |
|
| 47 | 19 | $this->loadComponent('Security'); |
|
| 48 | 19 | $this->loadComponent('Authentication.Authentication'); |
|
| 49 | 19 | $this->Authentication->allowUnauthenticated(['login', 'logout']); |
|
| 50 | 19 | } |
|
| 51 | |||
| 52 | public function isAuthorized($user) { |
||
|
0 ignored issues
–
show
|
|||
| 53 | // Admin can access every action |
||
|
0 ignored issues
–
show
|
|||
| 54 | if (isset($user['role']) && $user['role'] === 'admin') { |
||
| 55 | return true; |
||
| 56 | } |
||
| 57 | |||
| 58 | // Default permit |
||
|
0 ignored issues
–
show
|
|||
| 59 | return true; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Before render callback. |
||
| 64 | * |
||
| 65 | * @param \Cake\Event\Event $event The beforeRender event. |
||
|
0 ignored issues
–
show
|
|||
| 66 | * @return \Cake\Network\Response|null|void |
||
|
0 ignored issues
–
show
|
|||
| 67 | */ |
||
| 68 | 15 | public function beforeRender(EventInterface $event) { |
|
|
0 ignored issues
–
show
|
|||
| 69 | 15 | if (!array_key_exists('_serialize', $this->viewBuilder()->getVars()) && |
|
|
0 ignored issues
–
show
|
|||
| 70 | 15 | in_array($this->response->getType(), ['application/json', 'application/xml']) |
|
|
0 ignored issues
–
show
|
|||
| 71 | ) { |
||
| 72 | $this->set('_serialize', true); |
||
| 73 | } |
||
| 74 | 15 | } |
|
| 75 | |||
| 76 | } |
||
| 77 |