Add frontend user authentication and document restriction to pimcore 5.0.
- Pimcore 5.
Get the Pimcore4 Version here.
- Create Members in Backend
- Allow Members to register in frontend
- Restrict Documents, Objects and Assets to specific User Roles
Please read the installation instructions before going deep with Members!
- Add code below to your
composer.json
"require" : {
"dachcom-digital/members" : "~2.0.0"
}
2.1 Activate & install it through backend. 2.2 Via CLI:
bin/console pimcore:bundle:enable MembersBundle
bin/console pimcore:bundle:install MembersBundle
# optional:
bin/console members:install:class
# optional to be sure assets are symlinked:
bin/console assets:install --symlink --relative
Members does not include any routes per default. Otherwise it would be hard for you to change or override included routes.
Include all Routes
# app/config/routing.yml
app:
resource: '@MembersBundle/Resources/config/pimcore/routing/all.yml'
Just include some Routes
# app/config/routing.yml
members_auth:
resource: '@MembersBundle/Resources/config/pimcore/routing/auth.yml'
prefix: /{_locale}/members #change your prefix if you have to.
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 | Note: Do not add this field if you're using the CMF. | |
confirmationToken | Input | must set to it read only |
lastLogin | Date & Time | must set to it read only |
password | Password | Hide it, if you want. Note: Do not add this field if you're using the CMF. |
passwordRequestedAt | Date & Time | must 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.
If you want to use the Customer Data Framework you need to do some further work. Read more about it here.
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.
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
- Groups
- Roles
- Use LuceneSearch with Members
- Use the Pimcore Customer Framework with Members
Learn more about the Members Restriction feature:
- Brief Overview
- Restricted Navigation
- Restricted Routing
- Restricted Listing
- Protected Asset Downloader
Before updating, please check our upgrade notes!
Copyright: DACHCOM.DIGITAL
For licensing details please visit LICENSE.md