1

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

1

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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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