HWIOauthBundle not redirecting to desired path after login

1.7k views Asked by At

I did as per documentation and resources from the Internet. but it is not redirecting user to default_target_path specified

here is my security.yml

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    firewalls:
        secured_area:
            pattern: ^/user
            anonymous: ~
            oauth:
                remember_me: true
                resource_owners:
                    facebook:           "/user/login/check-facebook"
#                    google:             "/login/check-google"
#                    my_custom_provider: "/login/check-custom"
                login_path:          /user/login
                check_path:          /user/connect
                use_forward:         false
                failure_path:        /user/login
                default_target_path: /user/like

                provider: fos_userbundle
                oauth_user_provider:
#                     oauth: ~
                     service: hwi_oauth.user.provider.fosub_bridge

            logout: true

    access_control:
        - { path: ^/user/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/user/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/user(.*), roles: ROLE_USER }

and config.yml is

hwi_oauth:
    # name of the firewall in which this bundle is active, this setting MUST be set
    firewall_name: secured_area
    connect:
            confirmation: true
    resource_owners:
        facebook:
            type:                facebook
            client_id:           id
            client_secret:       secret
            scope:               "email user_birthday"
            paths:
                email:          email
                birthday: user_birthday

    fosub:
        # try 30 times to check if a username is available (foo, foo1, foo2 etc)
        username_iterations: 30

        # mapping between resource owners (see below) and properties
        properties:
            facebook: fbID

fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: Auth\UserBundle\Entity\User

at the end it redirect me to ,

http://myurl/user/connect/service/facebook?key=1415715954

and displays output text as header.success

what should I do?

1

There are 1 answers

0
Vaibhav Dhage On BEST ANSWER

There was Typo there, simple mistake. as @StivenLlup suggested in comments,

I changed

access_control:
        - { path: ^/user/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/user/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/user(.*), roles: ROLE_USER } # changed this

to

access_control:
            - { path: ^/user/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/user/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/user/, roles: ROLE_USER } # to this

If HWIOauthBundle service can't find correct path to redirect like /user/like then this problem occurs

also if there is error in controller of specified path then also proper redirection does not work

adding correct path in access_control solved it.