簡體   English   中英

HWIOauthBundle - Facebook登錄 - Symfony3

[英]HWIOauthBundle - Facebook Login - Symfony3

我已經將HWIOauthBundle + FOSUserBundle實現到我的應用程序中,部分工作正常。

使用和不使用facebook時,登錄工作正常,但如果我使用不存在或密碼錯誤的用戶正常登錄,則會將我重定向到/ connect route(因為HWIOauthBundle)。

我怎么解決這個問題? 如果出現問題,請查看FOSUserBundle返回的/ login_check。 我不想用facebook登錄。

我的security.yml代碼:

# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html
security:
    encoders:
        FOS\UserBundle\Model\UserInterface: bcrypt

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email

    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_token_generator: security.csrf.token_manager

            oauth:
                resource_owners:
                    facebook: '/login'
                login_path: /connect
                failure_path: /connect

                oauth_user_provider:
                    service: hwi_oauth.user.provider.fosub_bridge
            logout: true
            anonymous: true
            remember_me:
                secret:   '%secret%'
                lifetime: 604800 # 1 week in seconds
                path:     /
                # by default, the feature is enabled by checking a
                # checkbox in the login form (see below), uncomment the
                # following line to always enable it.
                #always_remember_me: true


    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin, roles: ROLE_ADMIN }
        - { path: ^/shipment, roles: ROLE_USER }

我的routing.yml代碼:

# app/config/routing.yml
hwi_oauth_redirect:
    resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
    prefix:   /connect

hwi_oauth_connect:
    resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
    prefix:   /connect

hwi_oauth_login:
    resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
    prefix:   /connect

facebook_login:
    path: /login/check-facebook

# main login.
AppBundle:
    resource: "@AppBundle/Controller/"
    type:     annotation

FrontendBundle:
    resource: "@FrontendBundle/Controller/"
    type:     annotation

FOSUserBundle:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

FOSMessageBundle:
    resource: "@FOSMessageBundle/Resources/config/routing.xml"
    prefix:   /messenger

MyDinxxUserBundle:
    resource: "@UserBundle/Controller/"
    type:     annotation

請嘗試在security.yml中將facebook路徑從'/ login'更改為'/ login / check-facebook'。

oauth:
    resource_owners:
        facebook: '/login/check-facebook'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM