src/Admin/Service/ScreenLockerService.php line 43
<?phpnamespace App\Admin\Service;use Symfony\Component\HttpFoundation\RequestStack;use Symfony\Component\HttpFoundation\RedirectResponse;use App\Admin\Modules\User\Service\UserService;class ScreenLockerService{private $_requestStack;private $_userService;private $_sessionKey = 'admin.screen_locker.locked';public function __construct(RequestStack $requestStack,UserService $userService){$this->_requestStack = $requestStack;$this->_userService = $userService;}public function lock(){$this->_requestStack->getMainRequest()->getSession()->set($this->_sessionKey, true);}public function unlock($pin){if ($pin != $this->_userService->getLoggedUser()->getScreenLockerPin())return false;$this->_requestStack->getMainRequest()->getSession()->set($this->_sessionKey, false);return true;}public function checkLock(){$request = $this->_requestStack->getMainRequest();if ($request->isXmlHttpRequest() ||!$request->getSession()->get($this->_sessionKey) ||$request->get('_route') == 'admin_screen_locker_unlock_ajax' ||!$this->_userService->getLoggedUser())return;$this->_userService->logout();$response = new RedirectResponse($request->getRequestUri());$response->send();exit();}}