Customers get whoops.... after registering
mastrip2 opened this issue · 15 comments
Has anyone had any issues with customers getting the "whoops, our bad..." page not found error after registering for a account? It seems like the redirect that is done by default from magento isnt executing when the extension is enabled. If I turn it off the registering works.
Magento ver. 2.3.3 CE
Force Login Module Version : 4.0.2
Third party modules :
Magezon_PageBuilder
Mageplaza_CustomerApproval
Steps to reproduce
- Go to account register page and register
- click register
Expected result
- To be redirected back to the customer login page ( customer/account/login )
Actual result
I had used the code from #178 as a reference of code to specifically target the registration url and ignore it. Its probably a better way of fixing this issue but I was under alot of pressure to quickly fix the issue. I'll try and find it and post it here as a fix
I had used the code from #178 as a reference of code to specifically target the registration url and ignore it. Its probably a better way of fixing this issue but I was under alot of pressure to quickly fix the issue. I'll try and find it and post it here as a fix
Can you provide a more detailed description/guide on how you solved the issue?
Much appreciated!
@mastrip2 can you provide us some code how to fix the issue?
I downloaded the Batao.zip code from issue #178 . Then I browsed to the Plugin/Frontend/BitExpert/ForceCustomerLogin/Controller and edited the LoginCheck.php file. Inside the afterExcute function I added a way to check the current url and see if it was the url I observed to be for creating users. If it was I overrode the default way the extension redirected the user causing the error. Below is the code that im currently using. You just have to fix the namespace since I used a different one then the original.
`
<?php
namespace {New Name Space Here}\Register\Plugin\Frontend\BitExpert\ForceCustomerLogin\Controller;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Response\Http as ResponseHttp;
/**
* Class LoginCheck
*
* @package {New Name space Here}\Register\Plugin\Frontend\BitExpert\ForceCustomerLogin\Controller
*/
class LoginCheck
{
/**
* @var \Magento\Framework\UrlInterface
*/
private $url;
/**
* @var ResponseHttp
*/
private $response;
private $request;
public function __construct(
\Psr\Log\LoggerInterface $logger,
Context $context,
ResponseHttp $response
) {
$this->logger = $logger;
$this->url = $context->getUrl();
$this->response = $response;
$this->request = $context->getRequest();
}
public function afterExecute(
\BitExpert\ForceCustomerLogin\Controller\LoginCheck $subject,
$result
) {
$this->logger->info('scanning url');
$url = $this->url->getCurrentUrl();
$this->logger->info($url);
if($this->request->isPost()){
return false;
}
if (strpos($url, 'customer/account/createpost')!== false) {
$this->logger->info('matched');
$this->response->setNoCacheHeaders();
$this->response->setRedirect('/customer/account');
$this->response->sendResponse();
return true;//it matched the register redirect
}
$this->logger->info('do nothing');
return $result;//let it be
}
}
Theres probably a better way of doing this but I kind of need a fix a bit quickly and I didnt see anything in the original code that explained what was causing this
@shochdoerfer @mastrip2 I can add an extended solution as provided for the password reset handling we recently fixed (see https://github.com/bitExpert/magento2-force-login/blob/master/Controller/LoginCheck.php#L148 and https://github.com/bitExpert/magento2-force-login/blob/master/Controller/PasswordResetHelper.php). Maybe some hook / event to loosely couple the logic and allow customized logic to be attached.
@websharp sure, if you have the time to take a look, go ahead. Not sure if we need to make the logic customizable.
This issue is still a thing, after registration we get redirect to createpost url as a GET.
Thats resulting in a 404. The fix above does not quite work how can we redirect back to the login and not de previous url.
You could redirect to the customer/account/login
just change the set redirect function (code above)
This issue is still a thing, after registration we get redirect to createpost url as a GET.
Thats resulting in a 404. The fix above does not quite work how can we redirect back to the login and not de previous url.
Same here
@shochdoerfer Sorry for the delay, I provided the suggested fix in #186
master
still 404's for us
@mastrip2 @mustafaeyvazvaimo @davidwindell we added some fixes to the master, do you mind testing your issue, if everything works fine now or report any new issue occured?
@mastrip2 @mustafaeyvazvaimo @davidwindell we added some fixes to the master, do you mind testing your issue, if everything works fine now or report any new issue occured?
Seems ok to me. Thanks for the update.
I am still getting this issue in 4.1.0 unfortunately, any ideas why this may be?