BitBagCommerce / SyliusVueStorefrontPlugin

Sylius plugin integrating Sylius with Vue Storefront
45 stars 24 forks source link

Login functionality #83

Closed dperkosan closed 4 years ago

dperkosan commented 4 years ago

In order for login to work, in security.yaml, insted of this:

      vs_bridge_user_login:
            pattern: "%bitbag.vue_storefront.security.regex%/user/login"
            stateless: true
            anonymous: true
            provider: sylius_shop_user_provider
            json_login:
                provider: sylius_shop_user_provider
                check_path: /vsbridge/user/login
                password_path: password
                success_handler: bitbag_sylius_vue_storefront_plugin.lexik_jwt_authentication.handler.authentication_success
                failure_handler: bitbag_sylius_vue_storefront_plugin.lexik_jwt_authentication.handler.authentication_failure
                require_previous_session: false

        vs_bridge:
            pattern: "%bitbag.vue_storefront.security.regex%"
            stateless: true
            anonymous: true
            provider: sylius_shop_user_provider
            guard:
                provider: sylius_shop_user_provider
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator```

should be:
   vs_bridge:
        pattern: "%bitbag.vue_storefront.security.regex%"
        stateless: true
        anonymous: true
        provider: sylius_shop_user_provider
        json_login:
            provider: sylius_shop_user_provider
            check_path: /vsbridge/user/login
            password_path: password
            success_handler: bitbag_sylius_vue_storefront_plugin.lexik_jwt_authentication.handler.authentication_success
            failure_handler: bitbag_sylius_vue_storefront_plugin.lexik_jwt_authentication.handler.authentication_failure
            require_previous_session: false
        guard:
            authenticators:
                - lexik_jwt_authentication.jwt_token_authenticator```
medteck commented 4 years ago

I'm having this error when I try to login from VSF. Unable to find the controller for path "/vsbridge/user/login". The route is wrongly configured.

But your solution didn't work either. Any idea ?

Codeweld commented 4 years ago

This problem is related to an order of firewalls in your security.yaml file. Configuration from the README should be put first before any other firewalls, just like that:

security:
    always_authenticate_before_granting: true
    providers:
        sylius_admin_user_provider:
            id: sylius.admin_user_provider.email_or_name_based
        sylius_shop_user_provider:
            id: sylius.shop_user_provider.email_or_name_based
    encoders:
        Sylius\Component\User\Model\UserInterface: argon2i
    firewalls:
        vs_bridge_user_login:
            pattern: "%bitbag.vue_storefront.security.regex%/user/login"
            stateless: true
            anonymous: true
            provider: sylius_shop_user_provider
            json_login:
                provider: sylius_shop_user_provider
                check_path: /vsbridge/user/login
                password_path: password
                success_handler: bitbag_sylius_vue_storefront_plugin.lexik_jwt_authentication.handler.authentication_success
                failure_handler: bitbag_sylius_vue_storefront_plugin.lexik_jwt_authentication.handler.authentication_failure
                require_previous_session: false

        vs_bridge:
            pattern: "%bitbag.vue_storefront.security.regex%"
            stateless: true
            anonymous: true
            provider: sylius_shop_user_provider
            guard:
                provider: sylius_shop_user_provider
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator

I'll add a note about it to the README and I'm closing this issue.