Veriteworks / CookieFix

Fix Magento2.2/2.3/2.4 Cookie SameSite attribute
Academic Free License v3.0
65 stars 35 forks source link

Customer login error message on Magento 2.4.1 #25

Closed onahkenneth closed 3 years ago

onahkenneth commented 3 years ago

User can login but error message displayed after redirect to customer dashboard An unspecified error occurred. Please contact us for assistance

3ds payment works on Chrome/Firefox as expected but it caused issue with user login with Chrome/Firefox.

Further debugging yielded this stack trace

Cookie must be secure in order to use the SameSite None directive.

#0 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/veriteworks/cookiefix/Plugin/SwitchSameSite.php(67): Magento\Framework\Stdlib\Cookie\CookieMetadata->setSameSite()
#1 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(121): Veriteworks\CookieFix\Plugin\SwitchSameSite->beforeSetPublicCookie()
#2 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\Stdlib\Cookie\PhpCookieManager\Interceptor->Magento\Framework\Interception\{closure}()
#3 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/generated/code/Magento/Framework/Stdlib/Cookie/PhpCookieManager/Interceptor.php(23): Magento\Framework\Stdlib\Cookie\PhpCookieManager\Interceptor->___callPlugins()
#4 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/App/PageCache/FormKey.php(74): Magento\Framework\Stdlib\Cookie\PhpCookieManager\Interceptor->setPublicCookie()
#5 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/module-page-cache/Observer/RenewFormKey.php(91): Magento\Framework\App\PageCache\FormKey->set()
#6 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/module-page-cache/Observer/RenewFormKey.php(77): Magento\PageCache\Observer\RenewFormKey->setNewFormKey()
#7 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Magento\PageCache\Observer\RenewFormKey->execute()
#8 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod()
#9 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch()
#10 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch()
#11 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/module-customer/Model/Session.php(469): Magento\Framework\Event\Manager\Proxy->dispatch()
#12 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/module-customer/Controller/Account/LoginPost.php(192): Magento\Customer\Model\Session->setCustomerDataAsLoggedIn()
#13 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Customer\Controller\Account\LoginPost->execute()
#14 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Customer\Controller\Account\LoginPost\Interceptor->___callParent()
#15 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/module-customer/Controller/Plugin/Account.php(64): Magento\Customer\Controller\Account\LoginPost\Interceptor->Magento\Framework\Interception\{closure}()
#16 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Customer\Controller\Plugin\Account->aroundExecute()
#17 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/App/Action/Plugin/ActionFlagNoDispatchPlugin.php(51): Magento\Customer\Controller\Account\LoginPost\Interceptor->Magento\Framework\Interception\{closure}()
#18 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Framework\App\Action\Plugin\ActionFlagNoDispatchPlugin->aroundExecute()
#19 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Customer\Controller\Account\LoginPost\Interceptor->Magento\Framework\Interception\{closure}()
#20 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/generated/code/Magento/Customer/Controller/Account/LoginPost/Interceptor.php(23): Magento\Customer\Controller\Account\LoginPost\Interceptor->___callPlugins()
#21 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/App/Action/Action.php(111): Magento\Customer\Controller\Account\LoginPost\Interceptor->execute()
#22 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch()
#23 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Customer\Controller\Account\LoginPost\Interceptor->___callParent()
#24 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Customer\Controller\Account\LoginPost\Interceptor->Magento\Framework\Interception\{closure}()
#25 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/generated/code/Magento/Customer/Controller/Account/LoginPost/Interceptor.php(32): Magento\Customer\Controller\Account\LoginPost\Interceptor->___callPlugins()
#26 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/App/FrontController.php(186): Magento\Customer\Controller\Account\LoginPost\Interceptor->dispatch()
#27 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/App/FrontController.php(118): Magento\Framework\App\FrontController->processRequest()
#28 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
#29 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()
#30 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/vaimo/module-redirect/Plugin/Framework/FrontControllerPlugin.php(34): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#31 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(135): Vaimo\Redirect\Plugin\Framework\FrontControllerPlugin->aroundDispatch()
#32 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(99): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#33 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch()
#34 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(71): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#35 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch()
#36 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#37 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()
#38 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
#39 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch()
#40 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->___callParent()
#41 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#42 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->___callPlugins()
#43 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/vendor/magento/framework/App/Bootstrap.php(263): Magento\Framework\App\Http\Interceptor->launch()
#44 /opt/vaimo/deploy/x11038/2021-02-12_15-53-19/htdocs/pub/index.php(40): Magento\Framework\App\Bootstrap->run()
#45 {main}
HirokazuNishi commented 3 years ago

@onahkenneth

Could you check your cookies? Session cookie has secure flag? If your website runs under https, the cookie should have secure flag.

onahkenneth commented 3 years ago

@HirokazuNishi You are right. I had to patch the this vendor/magento/module-page-cache/Observer/RenewFormKey.php class by adding this line $cookieMetadata->setSecure($this->sessionConfig->getCookieSecure());

HirokazuNishi commented 3 years ago

@onahkenneth Then your case was solved?

onahkenneth commented 3 years ago

@HirokazuNishi Yes it is