我已经在我的应用程序中实现了HWIOauthBundle + FOSUserBundle,它正在部分地工作。
无论有没有facebook,登录都是完美的,但是,如果我使用一个不存在的用户或错误的密码正常登录,它会将我重定向到/connect路由(因为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发布于 2017-05-29 22:38:50
请尝试在security.yml中将facebook路径从'/login‘更改为'/login/check-facebook’。
oauth:
resource_owners:
facebook: '/login/check-facebook'https://stackoverflow.com/questions/44240162
复制相似问题