I want to know what does the formkey validator do : Magento\Framework\Data\Form\FormKey\Validator

up vote 1 down vote accepted

Simply and in order :

  1. Magento/Framework/Data/Form/FormKey::getFormKey() : generate a formkey.

  2. Magento/Framework/Data/Form/FormKey/Validator::validate() validate that formkey.

Exemple : vendor/magento/module-customer/Controller/Account::LoginPost.php

public function execute()
{
    if ($this->session->isLoggedIn() || !$this->formKeyValidator->validate($this->getRequest())) {
        ...
        return $resultRedirect;
    }

Here magento check : if a user is already logged in $this->session->isLoggedIn() or a formkey request is not valide !$this->formKeyValidator->validate($this->getRequest()), it returns and redirects to the previous page.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.