l91/sulu-website-user-bundle

Sulu 网站登录、注册、双重确认、密码找回/重置、个人资料组件

1.0.0-RC4 2016-06-05 11:55 UTC

This package is auto-updated.

Last update: 2024-09-21 19:37:20 UTC


README

我们已经搬家了!!!

我们对 1.3.0 版本的组件进行了完全重写。请使用以下组件进行未来所有使用:

https://github.com/sulu/SuluCommunityBundle

何时使用它?

当您使用 Sulu 构建一个应用程序、内部网、商店等,其中用户可以登录、注册并需要在网站上管理他们的联系信息时。此组件将提供您所需的所有基本功能。

  • 网站安全用户角色
  • 登录表单
  • 注册表单
  • 密码找回/重置表单
  • 个人资料表单
  • 双重确认、单次确认或管理员激活
  • 每项操作的通知电子邮件(用户+管理员)
  • 多 WebSpace 支持

安装

0. 使用 composer 安装

composer require l91/sulu-website-user-bundle:~1.0
composer install

1. 将安全组件添加到 WebsiteKernel

app/WebsiteKernel.php:

$bundles[] = new Symfony\Bundle\SecurityBundle\SecurityBundle();

2. 将组件添加到 AbstractKernel

app/AbstractKernel.php:

new L91\Sulu\Bundle\WebsiteUserBundle\L91SuluWebsiteUserBundle(),

3. 将新路由添加到路由配置中

app/config/website/routing.ymlapp/config/admin/routing.yml

l91_sulu_website_user:
    type: portal
    resource: "@L91SuluWebsiteUserBundle/Resources/config/routing.yml"

4. 将安全系统添加到您的 webspace

app/Resources/webspaces/<your_webspace>.xml:

    <security>
        <system>Website</system>
    </security>

5. 更新您的网站安全文件

app/config/website/security.yml:

示例

security:
    session_fixation_strategy: none

    access_decision_manager:
        strategy: affirmative

    acl:
        connection: default

    encoders:
        Sulu\Bundle\SecurityBundle\Entity\User:
            algorithm: sha512
            iterations: 5000
            encode_as_base64: false

    providers:
        sulu:
            id: sulu_security.user_provider

    access_control:
        - { path: /profile, roles: ROLE_USER }

    firewalls:
        website:
            pattern: (login|profile|logout)
            anonymous: ~
            form_login:
                login_path: l91_sulu_website_user.login
                check_path: l91_sulu_website_user.login
            logout:
                path: l91_sulu_website_user.logout
                target: l91_sulu_website_user.login

sulu_security:
    checker:
        enabled: true

6. 创建您的模板

在您的主题下 <your_theme>/templates/security 中创建以下模板。(以https://github.com/alexander-schranz/sulu-website-user-bundle/tree/master/Resources/themes/default/templates/security 中的示例为例)

  • login.html.twig
  • registration.html.twig
  • confirmation.html.twig
  • password-forget.html.twig
  • password-reset.html.twig
  • profile.html.twig
  • emails/registration-user.html.twig
  • emails/password-forget-user.html.twig
  • embed/login.html.twig

使用您的组件更新 Liip Theme Bundle

sulu/sulu#1966

app/config/config.yml:

liip_theme:
    path_patterns:
        app_resource:
            - %%app_path%%/../../src/Client/Bundle/WebsiteBundle/Resources/themes/%%current_theme%%/%%template%%

7. 设置配置

app/config/config.yml:

基本

l91_sulu_website_user:
    webspaces:
        <webspace_key>:
            from: no-reply@example.at

扩展

l91_sulu_website_user:
    webspaces:
        <webspace_key>:
            from: no-reply@example.at
            to: ~
            reply_to: ~
            subject: ~
            role: Website
            form_types:
                contact: L91\Sulu\Bundle\WebsiteUserBundle\Form\Type\ContactType
                contact_address: L91\Sulu\Bundle\WebsiteUserBundle\Form\Type\ContactAddressType
                address: L91\Sulu\Bundle\WebsiteUserBundle\Form\Type\ContactAddressType
            login:
                from: ~
                to: ~
                reply_to: ~
                subject: ~
                templates:
                    form: '::templates/security/login.html.twig'
                    form_embed: '::templates/security/embed/login.html.twig'
                    admin: ~
                    user: ~
            registration:
                from: ~
                to: ~
                reply_to: ~
                subject: ~
                activate_user: false
                form_type: 'L91\Sulu\Bundle\WebsiteUserBundle\Form\Type\RegistrationType'
                templates:
                    form: '::templates/security/registration.html.twig'
                    admin: ~
                    user: '::templates/security/emails/registration-user.html.twig'
            confirmation:
                from: ~
                to: ~
                reply_to: ~
                subject: ~
                activate_user: true
                form_type: 'L91\Sulu\Bundle\WebsiteUserBundle\Form\Type\ConfirmationType'
                templates:
                    form: '::templates/security/confirmation.html.twig'
                    admin: ~
                    user: ~
            password_forget:
                from: ~
                to: ~
                reply_to: ~
                subject: ~
                form_type: 'L91\Sulu\Bundle\WebsiteUserBundle\Form\Type\PasswordForgetType'
                templates:
                    form: '::templates/security/password-forget.html.twig'
                    admin: ~
                    user: '::templates/security/emails/password-forget-user.html.twig'
            password_reset:
                from: ~
                to: ~
                reply_to: ~
                subject: ~
                form_type: 'L91\Sulu\Bundle\WebsiteUserBundle\Form\Type\PasswordResetType'
                templates:
                    form: '::templates/security/password-reset.html.twig'
                    admin: ~
                    user: ~
            profile:
                from: ~
                to: ~
                reply_to: ~
                subject: ~
                form_type: 'L91\Sulu\Bundle\WebsiteUserBundle\Form\Type\ProfileType'
                templates:
                    form: '::templates/security/profile.html.twig'
                    admin: ~
                    user: ~