FosUserBundle

Questions around the Aimeos bundle for the Symfony framework
Forum rules
Always add your Symfony, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
garwat82
Posts: 16
Joined: 18 Dec 2014, 11:07

FosUserBundle

Post by garwat82 » 26 Jan 2015, 14:35

Hey

I've managed to integrate the Symfony FosUserBundle (https://github.com/FriendsOfSymfony/FOSUserBundle) for registration, authentication and password reminder into my Aimeos Symfony project.
Are you also interested in using this in Aimeos instead of the current solution?

Regards,

Garret

User avatar
aimeos
Administrator
Posts: 3097
Joined: 01 Jan 1970, 00:00

Re: FosUserBundle

Post by aimeos » 26 Jan 2015, 15:36

Hi Garret

Sure, every contribution is welcome!

garwat82
Posts: 16
Joined: 18 Dec 2014, 11:07

Re: FosUserBundle

Post by garwat82 » 30 Jan 2015, 14:17

Hey

The necessary changes have been committed and as far as I can see, the tests for the core and the Symfony adapter succeed now.
There's a pull request for the Symfony bundle as well and it may require some more attention because I've only added the FosUser entity and that's no used by default.

Regards,

Garret

garwat82
Posts: 16
Joined: 18 Dec 2014, 11:07

Re: FosUserBundle

Post by garwat82 » 30 Jan 2015, 17:56

The test are now working like expected

Garret

User avatar
aimeos
Administrator
Posts: 3097
Joined: 01 Jan 1970, 00:00

Re: FosUserBundle

Post by aimeos » 30 Jan 2015, 18:19

Great! How does it work?
Maybe we can write some documentation for it.

garwat82
Posts: 16
Joined: 18 Dec 2014, 11:07

Re: FosUserBundle

Post by garwat82 » 30 Jan 2015, 19:47

I've used 2.0 branch of the FosUserBundle and I've added this to the require section of my composer.json:

Code: Select all

"friendsofsymfony/user-bundle": "~2.0@dev"
In AppKernel::registerBundles() the bundle must be registered:

Code: Select all

new FOS\UserBundle\FOSUserBundle(),
The config.yml needs these settings and I've used the secure Bcrypt encryption:

Code: Select all

fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: aimeos_myaccount
    user_class: Aimeos\ShopBundle\Entity\FosUser

aimeos_shop:
    classes:
        customer:
            manager:
                name: FosUser
    mshop:
        customer:
            manager:
                password:
                    name: Bcrypt
The user bundle routes must also be included in the routing.yml:

Code: Select all

fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"
The security.yml is the most complex file:

Code: Select all

security:
    providers:
        aimeos_customer:
            entity: { class: AimeosShopBundle:FosUser, property: username }

    encoders:
        Aimeos\ShopBundle\Entity\FosUser: bcrypt

    firewalls:
        aimeos_myaccount:
            pattern: ^/
            form_login:
                provider: aimeos_customer
                csrf_provider: form.csrf_provider
            logout:       true
            anonymous:    true

    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/myaccount, roles: ROLE_USER }
Hope this helps.

Post Reply