Prestashop: Hook displayBackOfficeTop not being called anymore on Login BO Page in 1.7.7

Created on 9 Oct 2020  路  15Comments  路  Source: PrestaShop/PrestaShop

Describe the bug

I can no longer read post parameters from backofficetop hook on login page on 1.7.7. Please see below example:

Expected behavior

PS 1.6.1 - 1.7.6:

public function hookDisplayBackOfficeTop($params)
{
    if (Tools::isSubmit('submitLogin')) {
        exit;
    }
}

Go to login page -> Submit -> Die as expected

PS 1.7.7:

public function hookDisplayBackOfficeTop($params)
{
    if (Tools::isSubmit('submitLogin')) {
        exit;
    }
}

Go to login page -> Submit -> Logged in (not expected)

1.7.7.x Bug CO Fixed Hook Minor Must-have Regression

All 15 comments

Thanks for opening this issue! We will help you to keep its state consistent

Hi @MathiasReker ,
Could you send the steps to reproduce the bug please ?
And screenshots if possible.
Thanks!

Hello @florine2623

  1. Add this code to a module at the DisplayBackOfficeTop hook:
public function hookDisplayBackOfficeTop($params)
{
    if (Tools::isSubmit('submitLogin')) {
        exit;
    }
}
  1. Go to BO
  2. Login
  3. Repeat process for 1.7.6 and 1.7.7 -> 1.7.7. The hook is not working in this area of 1.7.7

@MathiasReker I dont know what is the root cause for this issue but the current behavior seems to make sense 馃 .

When Login Page is displayed, following a GET request, a HTML response is sent => hookDisplayBackOfficeTop is triggered
When user submits a POST request to Login Page, if successfull, the user is redirected to its main page (usually it's dashboard).

It makes sense that a successfull authentication POST request to login process does not render template, and hookDisplayBackOfficeTop is a display hook.

Hi @MathiasReker,

I used ps_banner module.
image

I tried with PS1.7.6.8.
I cannot log in
image

I tried with 17.7.x branch
I can log in => no issue
Is this the exact problem?

Thanks!

@khouloudbelguith yes, the behavior is different. Something in 1.7.7 changes its behavior.

@matks thanks, I get your point. My issue is, that my module includes a brute force protection where I need to monitor the login attempts. I made this work for 1.6 - 1.7.6, but I cannot make it work in 1.7.7.

I have tried the different hooks, but I cannot do this:

        if (Tools::isSubmit('submitLogin')) {
            // do something
        }

Do you have a suggestion for another solution achieving this? :)

@MathiasReker,

Thanks for the clarification.
I鈥檒l add this to the debug roadmap so that it鈥檚 fixed. If you have already fixed it on your end or if you think you can do it, please do send us a pull request!
Thanks!

Ping @PrestaShop/product-team, I couldn't find the Epic related to this issue.
Can you check it!

Thank you!

Hi @MathiasReker so I checked and found the reason : https://github.com/PrestaShop/PrestaShop/pull/19712

Hook displayBackOfficeTop was being fired from this block:

        $this->context->smarty->assign([
            'displayBackOfficeTop' => Hook::exec('displayBackOfficeTop'),
            'submit_form_ajax' => (int) Tools::getValue('submitFormAjax'),
        ]);

This block has been moved from init() to initHeader()

@MathiasReker Have a look at the hooks being called in postProcess() I think they should do the job for your case

@matks I cannot solve the problem 馃槙 Can you point out what specific hook from the postProcess that I could use for this? 馃

hey @MathiasReker Have a look at #21435 You should be happy :)

@PierreRambaud Thanks! 馃憤馃徎

https://github.com/PrestaShop/PrestaShop/pull/21435 merged => @MathiasReker so the answer to your question "what should I use for 177" is "one of the new hooks" 馃槂

@matks Thanks for the new hooks, I really appreciate that. 馃憤馃徎

Was this page helpful?
0 / 5 - 0 ratings