Add frontend user authentication and document restriction to pimcore 5.0.
- Pimcore 5. Only with Build 105 or greater.
Get the Pimcore4 Version here.
- Create Members in Backend
- Allow Members to register in frontend
- Restrict Documents, Objects and Assets to specific User Roles
- Add code below to your
composer.json
- Activate & install it through backend
- Clear Cache
"require" : {
"dachcom-digital/members" : "dev-master",
}
Unlike members1, this bundle does not install any classes for you any more. Since Members should be the one and only frontend authentication Bundle, we need to add the most flexibility as possible. But no worries, it's still simple to integrate.
There is also a class installer command. If your not using any special class configuration, feel free to use this command:
$ bin/console members:install:class
You need two classes: User and Group. So let's create it:
User
- Create a class and call it
MembersUser
- Add parent class:
\MembersBundle\Adapter\User\AbstractUser
- Add fields:
Name | Field Type | Comment |
---|---|---|
userName | Input | |
Input | ||
confirmationToken | Input | set to it read only |
lastLogin | Date & Time | set to it read only |
password | Password | |
passwordRequestedAt | Date & Time | set to it read only |
groups | User Group | This field comes with Members |
membersUser
is the default name, you may want to change it. Read here how to achieve that.
Group
- Create a class and call it
MembersGroup
- Add parent class:
\MembersBundle\Adapter\Group\AbstractGroup
- Add fields:
Name | Field Type | Comment |
---|---|---|
name | Input | |
roles | Multiselection | Set "Options Provider Class or Service Name" to MembersBundle\CoreExtension\Provider\RoleOptionsProvider |
membersGroup
is the default name, you may want to change it. Read here how to achieve that.
Feel free to add additional fields since those are just the required ones. That's it. Members will use those classes to manage authentication and group management.
Navigation: Do not use the default nav builder extension (pimcore_build_nav
). Just use the members_build_nav
to build secure menus.
Otherwise your restricted pages will show up. This twig extension will also handel your navigation cache strategy.
Usage
{% set nav = members_build_nav(currentDoc, documentRootDoc, null, true) %}
{{ pimcore_render_nav(nav, 'menu', 'renderMenu', { maxDepth: 2 }) }}
You're almost there, just check the email configuration and you're good to go.
- Custom Class Names
- Frontend Routes & Views
- Available Events
- Custom Form Types
- Registration Types
- Email Configuration
- Roles
- Use LuceneSearch with Members
Before updating, please check our upgrade notes!
Copyright: DACHCOM.DIGITAL
For licensing details please visit LICENSE.md