* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShopBundle\Controller\Admin; use PrestaShopBundle\Service\Routing\Router as PrestaShopRouter; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Validator\Constraints as Assert; /** * Admin controller to manage security pages. */ class SecurityController extends FrameworkBundleAdminController { public function compromisedAccessAction(Request $request) { $requestUri = urldecode($request->query->get('uri')); $url = new Assert\Url(); $violations = $this->get('validator')->validate($requestUri, [$url]); if ($violations->count()) { return $this->redirect('dashboard'); } // getToken() actually generate a new token $username = $this->get('prestashop.user_provider')->getUsername(); $newToken = $this->get('security.csrf.token_manager') ->getToken($username) ->getValue(); $newUri = PrestaShopRouter::generateTokenizedUrl($requestUri, $newToken); return $this->render( '@PrestaShop/Admin/Security/compromised.html.twig', [ 'requestUri' => $newUri, ] ); } }