loadAuthComponents($this->getController()); } /** * Load all auth components needed: Authentication.Authentication, Authorization.Authorization and CakeDC/OneTimePasswordAuthenticator * * @param \Cake\Controller\Controller $controller Target controller * @return void * @throws \Exception */ protected function loadAuthComponents($controller) { $authenticationConfig = Configure::read('Auth.AuthenticationComponent'); if ($authenticationConfig['load'] ?? false) { unset($authenticationConfig['config']); $controller->loadComponent('Authentication.Authentication', $authenticationConfig); } if (Configure::read('Auth.AuthorizationComponent.enable') !== false) { $config = (array)Configure::read('Auth.AuthorizationComponent'); $controller->loadComponent('Authorization.Authorization', $config); } if (Configure::read('OneTimePasswordAuthenticator.login') !== false) { $controller->loadComponent('CakeDC/Auth.OneTimePasswordAuthenticator'); } } }