Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customers get whoops.... after registering #180

Closed
mastrip2 opened this issue Feb 18, 2020 · 15 comments
Closed

Customers get whoops.... after registering #180

mastrip2 opened this issue Feb 18, 2020 · 15 comments
Assignees

Comments

@mastrip2
Copy link

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

  1. Go to account register page and register
  2. click register

Expected result

  1. To be redirected back to the customer login page ( customer/account/login )

Actual result

  1. Get error "whoops, our bad" error page
    image
@beltoftandersen
Copy link

Getting the same on 2.3.4, which the 4.0.2.

Skærmbillede 2020-03-14 kl  23 06 21

Error url: /customer/account/createpost/

@mastrip2
Copy link
Author

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

@beltoftandersen
Copy link

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!

@shochdoerfer
Copy link
Member

@mastrip2 can you provide us some code how to fix the issue?

@mastrip2
Copy link
Author

mastrip2 commented Apr 14, 2020

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

@der-workfloh
Copy link
Contributor

@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.

@shochdoerfer
Copy link
Member

@websharp sure, if you have the time to take a look, go ahead. Not sure if we need to make the logic customizable.

@niekappartmedia
Copy link

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.

@mastrip2
Copy link
Author

You could redirect to the customer/account/login just change the set redirect function (code above)

@mustafaeyvazvaimo
Copy link

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

der-workfloh pushed a commit to der-workfloh/magento2-force-login that referenced this issue Jun 24, 2020
@der-workfloh
Copy link
Contributor

@shochdoerfer Sorry for the delay, I provided the suggested fix in #186

@davidwindell
Copy link

master still 404's for us

@der-workfloh
Copy link
Contributor

@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?

@der-workfloh der-workfloh self-assigned this Oct 21, 2020
@mustafaeyvazvaimo
Copy link

@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.

@joeybab3
Copy link

joeybab3 commented Aug 3, 2021

I am still getting this issue in 4.1.0 unfortunately, any ideas why this may be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants