1

I have a front end module that I have developed, which I want to restrict to logged in users only. Stressing this is front end users, not admin users we are talking about.

I assume this can be done through ACL settings in much the same way the admin modules do - however I can't find the answer anywhere.

Is this possible or is it necessary to check on every action that they are logged in (I want to avoid doing this as it has a large margin for error - I simply only want logged in users to access said pages)?

1

No, there is no ACL for the frontend. To allow access to logged in users in your custom controller, you can do it the same way as the Magento_Customer module, as described here: Magento 2 - Check login for page in custom module

If necessary, add an additional check for the customer group.

But if you want to be able to configure an ACL for customer groups, you'll have to implement that from scratch, although ou will probably be able to reuse some parts of the admin module.

0

I see it was been a lot of time ago but maybe this will be actual for some other people.

Looks like module "dized/module-front-acl" could be helpful: https://github.com/di-zed/m2-front-acl

ACL System for the Front Part of the Magento 2 project. The module that will allow you to take full advantage of the front-end ACL capabilities in the modules you develop.

Key Features:

  • Ability to create your own roles and permissions via XML file.
  • Ability to set default permissions for each of the roles.
  • Ability to set the necessary roles and permissions for each customer in the admin panel.
  • Ability to automatically set the default role and permissions for a newly created customer (using a plugin).
  • Ability to easily use this functionality for controllers/actions and blocks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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