User bundle
Installation
Install Packages
bash
$ composer require enhavo/user-bundle
bash
$ yarn add @enhavo/user
Update your config/packages/vue.yaml
yaml
enhavo_app:
vue:
route_providers:
# ...
admin:
type: routing
groups: ['admin']
Update your config/packages/security.yaml
yaml
security:
password_hashers:
Enhavo\Bundle\UserBundle\Model\UserInterface: auto
providers:
entity_user_provider:
entity:
class: Enhavo\Bundle\UserBundle\Model\User
firewalls:
# ...
admin:
pattern: ^/admin/?.*
context: user
user_checker: Enhavo\Bundle\UserBundle\Security\UserChecker
entry_point: Enhavo\Bundle\UserBundle\Security\EntryPoint\FormAuthenticationEntryPoint
custom_authenticators:
- Enhavo\Bundle\UserBundle\Security\Authentication\FormLoginAuthenticator
logout:
path: enhavo_user_security_logout
target: enhavo_user_security_login
main:
pattern: .*
context: user
access_control:
- { path: ^/admin/login$, role: PUBLIC_ACCESS }
- { path: ^/admin/api/login$, role: PUBLIC_ACCESS }
- { path: ^/admin/reset-password/.+, role: PUBLIC_ACCESS }
- { path: ^/admin/api/reset-password/.+, role: PUBLIC_ACCESS }
- { path: ^/admin/, role: ROLE_ADMIN }
Update your config/packages/enhavo.yaml
yaml
enhavo_app:
menu:
user:
type: user
Add enhavo_user.yaml
file to your routes folder config/routes
yaml
# config/routes/enhavo_user.yaml
enhavo_user_admin:
resource: "@EnhavoUserBundle/Resources/config/routes/admin/*"
prefix: /admin
enhavo_user_theme:
resource: "@EnhavoUserBundle/Resources/config/routes/theme/*"
prefix: /
Configuration
Register configuration
yaml
registration_register:
template: theme/security/registration/register.html.twig
redirect_route: enhavo_user_theme_registration_check
confirmation_route: enhavo_user_theme_registration_confirm
auto_login: true
auto_enabled: true
auto_verified: false
mail:
template: mail/security/registration.html.twig
subject: registration.mail.subject
sender_name: ~
content_type: text/plain
translation_domain: 'EnhavoUserBundle'
form:
class: Enhavo\Bundle\UserBundle\Form\Type\RegistrationType
options: [] # "register" validation group is added automatically
yaml
registration_check:
template: theme/security/registration/check.html.twig
yaml
registration_confirm:
template: 'theme/security/registration/confirm.html.twig'
mail:
template: 'mail/security/confirmation.html.twig'
subject: 'confirmation.mail.subject'
translation_domain: 'EnhavoUserBundle'
redirect_route: 'enhavo_user_theme_registration_finish'
yaml
registration_finish:
template: 'theme/security/registration/finish.html.twig'
Profile configuration
yaml
profile:
template: theme/resource/user/profile.html.twig
form:
class: Enhavo\Bundle\UserBundle\Form\Type\ProfileType
options: []
Reset password configuration
yaml
reset_password_request:
template: theme/security/reset-password/request.html.twig
mail_template: mail/security/reset-password.html.twig
mail_subject: reset_password.mail.subject
translation_domain: EnhavoUserBundle
redirect_route: enhavo_user_theme_reset_password_check
confirmation_route: enhavo_user_theme_reset_password_confirm
form:
class: Enhavo\Bundle\UserBundle\Form\Type\ResetPasswordRequestType
options: []
yaml
reset_password_check:
template: 'theme/security/reset-password/check.html.twig'
yaml
reset_password_confirm:
auto_login: true
template: 'theme/security/reset-password/confirm.html.twig'
redirect_route': 'enhavo_user_theme_reset_password_finish'
form:
class: Enhavo\Bundle\UserBundle\Form\Type\ResetPasswordType
options: []
yaml
reset_password_finish:
template: 'theme/security/reset-password/finish.html.twig'
Change email configuration
yaml
change_email_request:
template: theme/security/change-email/request.html.twig
mail_template: mail/security/change-email.html.twig
mail_subject: change_email.mail.subject
translation_domain: EnhavoUserBundle
redirect_route: enhavo_user_theme_change_email_check
confirmation_route: enhavo_user_theme_change_email_confirm
form:
class: ChangeEmailRequestType::class
options: []
yaml
change_email_check:
template: theme/security/change-email/check.html.twig
yaml
change_email_confirm:
template: theme/security/change-email/confirm.html.twig
redirect_route: enhavo_user_theme_change_email_finish
form:
class: ResetPasswordType::class
options: []
yaml
change_email_finish:
template: theme/security/change-email/finish.html.twig
Login configuration
yaml
login:
template: theme/security/login.html.twig
redirect_route: enhavo_user_theme_user_profile
route: enhavo_user_theme_security_login
check_route: enhavo_user_theme_security_login
verification_required: true
max_failed_login_attempts: 3
password_max_age: 3 days
Change password configuration
yaml
change_password:
form:
class: ChangePasswordFormType::class
options: []