1
我已經在應用程序中實現了HWIOauthBundle + FOSUserBundle,並且部分工作。HWIOauthBundle - Facebook登錄 - Symfony3
登錄可以完美地使用和不使用Facebook,但是如果我正常登錄的用戶不存在或密碼錯誤,它會將我重定向到/連接路由(因爲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
它的工作方式......它仍然重定向我,但現在在/登錄路線,並沒有錯誤。我認爲它應該在那個頁面上重定向我,但是出現錯誤。 – Kiddo
好吧,最後一個想法:嘗試在security.yml和routing.yml中將'/ connect'更改爲'/ login'。 –
所有/連接路由與/登錄? – Kiddo