1: <?php
2: namespace Opencart\Admin\Controller\Startup;
3: /**
4: * Class Permission
5: *
6: * @package Opencart\Admin\Controller\Startup
7: */
8: class Permission extends \Opencart\System\Engine\Controller {
9: /**
10: * Index
11: *
12: * @return \Opencart\System\Engine\Action|null
13: */
14: public function index(): ?\Opencart\System\Engine\Action {
15: if (isset($this->request->get['route'])) {
16: $pos = strrpos($this->request->get['route'], '.');
17:
18: if ($pos === false) {
19: $route = $this->request->get['route'];
20: } else {
21: $route = substr($this->request->get['route'], 0, $pos);
22: }
23:
24: // We want to ignore some pages from having its permission checked.
25: $ignore = [
26: 'common/dashboard',
27: 'common/login',
28: 'common/logout',
29: 'common/forgotten',
30: 'common/authorize',
31: 'common/language',
32: 'error/not_found',
33: 'error/permission'
34: ];
35:
36: if (!in_array($route, $ignore) && !$this->user->hasPermission('access', $route)) {
37: return new \Opencart\System\Engine\Action('error/permission');
38: }
39: }
40:
41: return null;
42: }
43: }
44: