1: <?php
2: namespace Opencart\Admin\Controller\Startup;
3: /**
4: * Class Login
5: *
6: * @package Opencart\Admin\Controller\Startup
7: */
8: class Login extends \Opencart\System\Engine\Controller {
9: /**
10: * Index
11: *
12: * @return \Opencart\System\Engine\Action
13: */
14: public function index(): ?object {
15: if (isset($this->request->get['route'])) {
16: $route = (string)$this->request->get['route'];
17: } else {
18: $route = '';
19: }
20:
21: // Remove any method call for checking ignore pages.
22: $pos = strrpos($route, '.');
23:
24: if ($pos !== false) {
25: $route = substr($route, 0, $pos);
26: }
27:
28: $ignore = [
29: 'common/login',
30: 'common/forgotten',
31: 'common/language'
32: ];
33:
34: // User
35: $this->registry->set('user', new \Opencart\System\Library\Cart\User($this->registry));
36:
37: if (!$this->user->isLogged() && !in_array($route, $ignore)) {
38: return new \Opencart\System\Engine\Action('common/login');
39: }
40:
41: $ignore = [
42: 'common/login',
43: 'common/logout',
44: 'common/forgotten',
45: 'common/language',
46: 'error/not_found',
47: 'error/permission'
48: ];
49:
50: if (!in_array($route, $ignore) && (!isset($this->request->get['user_token']) || !isset($this->session->data['user_token']) || ($this->request->get['user_token'] != $this->session->data['user_token']))) {
51: return new \Opencart\System\Engine\Action('common/login');
52: }
53:
54: return null;
55: }
56: }
57: