0

I want to build a custom controller, which works as follows:

  1. if user already have admin session, redirect user to admin page A
  2. if user does not have admin session, redirect user to storefront page B

Is there a way to achieve this?

First I tried building custom logic in adminhtml/controller but it didn't work because for case (2), magento shows admin login UI even before any of my controller logic runs. Then I tried building custom logic in frontend controller but that won't work for case (1) because it's not possible from frontend to tell admin session ( How to get admin session(user) details on front side in Magento 2? )

Any advise would be appreciated.

1 Answer 1

0

Try to use event controller_action_predispatch as it calls before any controller action dispatch

1
  • no luck, it seems like controller_action_predispatch runs for adminhtml_auth_login but not for my controller
    – Kazuki
    Commented Apr 9, 2020 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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