Quantcast
Channel: Neueste Diskussionen - Shopware Community Forum
Viewing all articles
Browse latest Browse all 14594

CSRF

$
0
0

Hallo,

ich bin neu bei Shopware und versuche meinen ersten Plug-In zu schreiben. Meine Aufgabe ist es zu verhindern, dass sich nicht angemeldete Benutzer nicht im Frontend bewegen können, sondern, dass dieser sich zuerst anmelden muss. Wie verwenden Shopware in der Version 5.2.2.

Mein Code sieht wie folgt aus:

public function onFrontendPreDispatch(Enlight_Event_EventArgs $args)
{
     /** @var \Enlight_Controller_Action $controller */
     $controller = $args->getSubject();

     /** @var Enlight_Controller_Request_RequestHttp $request */
     $request = $controller->Request();
     if($request->isDispatched()) {
     		if ( ($request->getControllerName() == 'register') || ($request->getControllerName() == 'account')) {
                return;
           }
           if (is_null(Shopware()->Session()->sUserId)) {
                $controller->redirect(array('controller' => 'account'));
           }
     }
}

 

Allerdings, verhindert CSRF das redirect und endet mit dem Fehler:

Shopware\Components\CSRFTokenValidationException: The provided X-CSRF-Token is invalid. Please go back, reload the page and try again. in /data/www/shopware-mario/20160714_5.2.2/engine/Shopware/Components/CSRFTokenValidator.php on line 151

 

Da wir den Schutz nicht ausschalten wollen,

https://developers.shopware.com/developers-guide/csrf-protection/

wie dieser im Beitrag vorgeschlagen ist, suche ich nach einer anderen Lösung.

 

Vielen Dank im Voraus.

 

Gruß

Mario


Viewing all articles
Browse latest Browse all 14594


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>