Skip to content

Commit

Permalink
Add documentation about FOSUser2
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed Apr 4, 2017
1 parent 2f2f7e2 commit 8052ad9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 78 deletions.
3 changes: 0 additions & 3 deletions Resources/doc/reference/advanced_configuration.rst
Expand Up @@ -21,7 +21,6 @@ Full configuration options:
# Authentication Form
form:
type: fos_user_profile
handler: fos_user.profile.form.handler.default
name: fos_user_profile_form
validation_groups: [Authentication] # Please note : this is not the default value
Expand Down Expand Up @@ -76,7 +75,6 @@ Full configuration options:
# You may customize the registration forms over here
form:
type: sonata_user_registration
handler: sonata.user.registration.form.handler.default
name: sonata_user_registration_form
validation_groups:
Expand Down Expand Up @@ -104,7 +102,6 @@ Full configuration options:
# Profile Form (firstname, lastname, etc ...)
form:
type: sonata_user_profile
handler: sonata.user.profile.form.handler.default
name: sonata_user_profile_form
validation_groups: [Profile]
Expand Down
82 changes: 7 additions & 75 deletions Resources/doc/reference/installation.rst
Expand Up @@ -7,13 +7,14 @@ Installation
Prerequisites
-------------

PHP 5.3 and Symfony 2 are needed to make this bundle work; there are also some Sonata dependencies that need to be installed and configured beforehand:
PHP 7 and Symfony 2.8 or 3 are needed to make this bundle work; there are also some Sonata dependencies that need to be installed and configured beforehand:

- `SonataAdminBundle <https://sonata-project.org/bundles/admin>`_
- `SonataEasyExtendsBundle <https://sonata-project.org/bundles/easy-extends>`_

You will need to install those in their 2.0 branches (or master if they don't
have a similar branch). Follow also their configuration step; you will find everything you need in their own installation chapter.
You will need to install those in their 2.0 or 3.0 branches. Follow also
their configuration step; you will find everything you need in their own
installation chapter.

.. note::
If a dependency is already installed somewhere in your project or in
Expand Down Expand Up @@ -46,14 +47,7 @@ Next, be sure to enable the bundles in your and ``AppKernel.php`` file:
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
// ...
// You have 2 options to initialize the SonataUserBundle in your AppKernel,
// you can select which bundle SonataUserBundle extends
// Most of the cases, you'll want to extend FOSUserBundle though ;)
// extend the ``FOSUserBundle``
new FOS\UserBundle\FOSUserBundle(),
new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'),
// OR
// the bundle will NOT extend ``FOSUserBundle``
new Sonata\UserBundle\SonataUserBundle(),
// ...
);
Expand Down Expand Up @@ -81,10 +75,10 @@ When using ACL, the ``UserBundle`` can prevent `normal` user to change settings
# app/config/security.yml
security:
# [...]
encoders:
FOS\UserBundle\Model\UserInterface: sha512
acl:
connection: default
Expand All @@ -111,7 +105,6 @@ Add these config lines
user_manager: sonata.user.orm.user_manager # If you're using doctrine orm (use sonata.user.mongodb.user_manager for mongodb)
doctrine:
dbal:
types:
json: Sonata\Doctrine\Types\JsonType
Expand All @@ -132,60 +125,6 @@ And these in the config mapping definition (or enable `auto_mapping <http://symf
SonataUserBundle: ~
FOSUserBundle: ~ # If SonataUserBundle extends it
Use custom SonataUser controllers and templates instead of FOSUser ones
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you wish to use custom ``SonataUserBundle`` templates and controllers instead of ``FOSUser`` ones, you will have to update your ``routing.yml`` file as follows:

Replace:

.. code-block:: yaml
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
With:

.. code-block:: yaml
sonata_user_security:
resource: "@SonataUserBundle/Resources/config/routing/sonata_security_1.xml"
sonata_user_resetting:
resource: "@SonataUserBundle/Resources/config/routing/sonata_resetting_1.xml"
prefix: /resetting
sonata_user_profile:
resource: "@SonataUserBundle/Resources/config/routing/sonata_profile_1.xml"
prefix: /profile
sonata_user_register:
resource: "@SonataUserBundle/Resources/config/routing/sonata_registration_1.xml"
prefix: /register
sonata_user_change_password:
resource: "@SonataUserBundle/Resources/config/routing/sonata_change_password_1.xml"
prefix: /profile
Integrating the bundle into the Sonata Admin Bundle
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -218,7 +157,7 @@ Then, add a new custom firewall handlers for the admin:
providers:
fos_userbundle:
id: fos_user.user_manager
id: fos_user.user_provider.username
firewalls:
# Disabling the security for the web debug toolbar, the profiler and Assetic.
Expand Down Expand Up @@ -267,11 +206,6 @@ The last part is to define 3 new access control rules:
security:
access_control:
# URL of FOSUserBundle which need to be available to anonymous users
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
# Admin login page needs to be accessed without credential
- { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
Expand Down Expand Up @@ -343,7 +277,6 @@ classes:
firewall_name: main
user_class: Application\Sonata\UserBundle\Entity\User
group:
group_class: Application\Sonata\UserBundle\Entity\Group
group_manager: sonata.user.orm.group_manager # If you're using doctrine orm (use sonata.user.mongodb.group_manager for mongodb)
Expand All @@ -352,7 +285,6 @@ classes:
user_manager: sonata.user.orm.user_manager # If you're using doctrine orm (use sonata.user.mongodb.user_manager for mongodb)
doctrine:
dbal:
types:
json: Sonata\Doctrine\Types\JsonType

0 comments on commit 8052ad9

Please sign in to comment.